# File.move command

**URL:** <https://rubytalk.org/t/file-move-command/39974>\
**Category:** ruby-talk\
**Created:** [16 August 2007 23:40 UTC](https://rubytalk.org/t/file-move-command/39974 "2007-08-16T23:40:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_B](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Mike\_B](https://rubytalk.org/u/Mike_B)\
**Post date:** [16 August 2007 23:40 UTC](https://rubytalk.org/t/file-move-command/39974/1 "2007-08-16T23:40:02Z")

</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:** ![Logan\_Capaldo](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Logan\_Capaldo](https://rubytalk.org/u/Logan_Capaldo)\
**Post date:** [16 August 2007 23:53 UTC](https://rubytalk.org/t/file-move-command/39974/2 "2007-08-16T23:53:34Z")

</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?

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

> **···**
>
> On 8/16/07, barjunk \<barjunk@attglobal.net\> wrote:
> 
> > Mike B.

---

<div class="post-metadata">

**Author:** ![Mike\_B](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Mike\_B](https://rubytalk.org/u/Mike_B)\
**Post date:** [16 August 2007 23:54 UTC](https://rubytalk.org/t/file-move-command/39974/3 "2007-08-16T23:54:58Z")

</div>

I forgot to add that it is ruby 1.8.4.

> **···**
>
> On Aug 16, 3:38 pm, barjunk \<barj...@attglobal.net\> wrote:
> 
> > 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:** ![Mike\_B](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Mike\_B](https://rubytalk.org/u/Mike_B)\
**Post date:** [17 August 2007 00:50 UTC](https://rubytalk.org/t/file-move-command/39974/4 "2007-08-17T00:50:02Z")

</div>

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.

> **···**
>
> On Aug 16, 3:53 pm, "Logan Capaldo" \<logancapa...@gmail.com\> wrote:
> 
> > On 8/16/07, barjunk \<barj...@attglobal.net\> wrote:
> > 
> > \> 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?
> > 
> > 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
> > 
> > \> Mike B.

---

<div class="post-metadata">

**Author:** ![Logan\_Capaldo](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@Logan\_Capaldo](https://rubytalk.org/u/Logan_Capaldo)\
**Post date:** [17 August 2007 01:03 UTC](https://rubytalk.org/t/file-move-command/39974/5 "2007-08-17T01:03:18Z")

</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?  
> \>  
> \> 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  
> \>  
> \> \> 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.

> **···**
>
> On 8/16/07, barjunk \<barjunk@attglobal.net\> wrote:
> 
> > On Aug 16, 3:53 pm, "Logan Capaldo" \<logancapa...@gmail.com\> wrote:  
> > \> On 8/16/07, barjunk \<barj...@attglobal.net\> wrote:  
> > But I'll try what you have suggested.
> > 
> > Mike B.
