[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

File.move command

barjunk

8/16/2007 11:39:00 PM

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.

4 Answers

barjunk

8/16/2007 11:51:00 PM

0

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.


I forgot to add that it is ruby 1.8.4.

Logan Capaldo

8/16/2007 11:54:00 PM

0

On 8/16/07, barjunk <barjunk@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.
>
>
>

barjunk

8/17/2007 12:50:00 AM

0

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.

I found it here:

http://www.ruby-doc.org/stdlib/libdoc/ftools/rdoc/...

But I'll try what you have suggested.

Mike B.

Logan Capaldo

8/17/2007 1:03:00 AM

0

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:
> >
> > > 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/...
>
Odd that it didn't work then, although I seem to recall that ftools is
deprecated in favor of FileUtils.
> But I'll try what you have suggested.
>
> Mike B.
>
>
>