# File.move command

**URL:** <https://www.ruby-forum.com/t/file-move-command/112283>\
**Category:** Ruby\
**Created:** [August 17, 2007, 1:40am UTC](https://www.ruby-forum.com/t/file-move-command/112283 "2007-08-17T01:40:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 17, 2007, 1:40am UTC](https://www.ruby-forum.com/t/file-move-command/112283/1 "2007-08-17T01:40:36Z")

</div>

I thought if I did:

File.move(“mydir”,“mynewdir”)

it would do a move…but it seems to make a file out of the directory  
I’m trying to move.

The end result I get is a file named mynewdir. What I want is a new  
directory containing all of the information in the mydir directory  
called mynewdir.

Am I going to have to use a copy and a rm of the old dir?

What’s the “right way” to do that?

Mike B.

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 17, 2007, 1:54am UTC](https://www.ruby-forum.com/t/file-move-command/112283/2 "2007-08-17T01:54:36Z")

</div>

On 8/16/07, barjunk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> called mynewdir.
> 
> Am I going to have to use a copy and a rm of the old dir?
> 
> What’s the “right way” to do that?

I can’t find a File::move, I dunno where you got it from (some lib?).  
One method is File::rename, another is to require ‘fileutils’ and use  
FileUtils.mv

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 17, 2007, 1:56am UTC](https://www.ruby-forum.com/t/file-move-command/112283/3 "2007-08-17T01:56:36Z")

</div>

On Aug 16, 3:38 pm, barjunk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Am I going to have to use a copy and a rm of the old dir?
> 
> What’s the “right way” to do that?
> 
> Mike B.

I forgot to add that it is ruby 1.8.4.

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 17, 2007, 2:51am UTC](https://www.ruby-forum.com/t/file-move-command/112283/4 "2007-08-17T02:51:40Z")

</div>

On Aug 16, 3:53 pm, “Logan C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > directory containing all of the information in the mydir directory  
> > Mike B.  
> > I found it here:

[http://www.ruby-doc.org/stdlib/libdoc/ftools/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/ftools/rdoc/index.html)

But I’ll try what you have suggested.

Mike B.

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 17, 2007, 3:04am UTC](https://www.ruby-forum.com/t/file-move-command/112283/5 "2007-08-17T03:04:41Z")

</div>

On 8/16/07, barjunk [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > The end result I get is a file named mynewdir. What I want is a new
> > 
> > > Mike B.
> 
> I found it here:
> 
> [http://www.ruby-doc.org/stdlib/libdoc/ftools/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/ftools/rdoc/index.html)

Odd that it didn’t work then, although I seem to recall that ftools is  
deprecated in favor of FileUtils.
