mv, move, or some way to move files in perl 
Author Message
 mv, move, or some way to move files in perl

is there a good way other than

system( "mv ..." );

to move directory trees across filesystems in perl? i could have sworn
that there used to be a mv function in File::Copy, but when i went looking
today, it wasn't there. but my memory of looking for something similar is
about a year old, so i could be wrong. i would also rather avoid

copy( ... );
unlink( ... );

why isn't there a File::Move module, incidentally?

any info or pointers to info come much appreciated.

-freddie



Sat, 03 Feb 2001 03:00:00 GMT  
 mv, move, or some way to move files in perl

Quote:
> to move directory trees across filesystems in perl? i could have
> sworn that there used to be a mv function in File::Copy, but when i
> went looking today, it wasn't there.

Hmm.  It's in both 5.004 and 5.005.  What perl version do you have?
Oh, BTW, it's called move(), not mv().  perldoc File::Copy.

--

http://pobox.com/~jdf/



Sat, 03 Feb 2001 03:00:00 GMT  
 mv, move, or some way to move files in perl


Quote:
> is there a good way other than

> system( "mv ..." );

> to move directory trees across filesystems in perl? i could have sworn
> that there used to be a mv function in File::Copy, but when i went looking

It's still there. You might need a failry recent version of perl. I'm
not sure which version included it initially.

Quote:
> today, it wasn't there. but my memory of looking for something similar is
> about a year old, so i could be wrong. i would also rather avoid

> copy( ... );
> unlink( ... );

You could try a rename(), and if that fails, fall back on a use
File::Copy; cp() (check the return value), followed by an unlink. That
is basically how mv(1) does it on some systems as well.

I don't know how much better it is than a system(mv), but it's at
least more portable.

Quote:
> why isn't there a File::Move module, incidentally?

feel free to write one and submit it to CPAN :)

Martien
--
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |



Sat, 03 Feb 2001 03:00:00 GMT  
 mv, move, or some way to move files in perl

Quote:

> is there a good way other than

> system( "mv ..." );

> to move directory trees across filesystems in perl? i could have sworn
> that there used to be a mv function in File::Copy, but when i went looking
> today, it wasn't there. but my memory of looking for something similar is
> about a year old, so i could be wrong. i would also rather avoid

> copy( ... );
> unlink( ... );

> why isn't there a File::Move module, incidentally?

> any info or pointers to info come much appreciated.

> -freddie

If memory serves me rigth there is function rename() in perl.
You should search http://www.perl.com/CPAN/ , I think you will
find some module there.

And I would also took a look into directory File in your perl library
directory.
Maybe something is already there.

If you happen to use Win95/WinNT and do not care about portability much,
you may
        use Win32::FileOp;      
         #http://jenda.krynicky.cz
        Move 'c:\some\directory\*.*' => 'd:\other\place';
         # remember, you are in M$ world, *.* matches even files
         # with no extension whatsoever! And Move() moves directories as well.

this module will provide you with fancy progress and confirmation
dialogs as well.

HTH, Jenda



Mon, 19 Feb 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. mv, move, or some way to move files in perl

2. ExtUtils::Command mv - move() not defined

3. html : how replace inner links in a html file when move a file

4. Needed: Script for file tree delete and file tree move

5. Finding files and moving them in perl

6. moving files and chmod via perl

7. Moving/Copying files with Perl

8. deleting, moving and renaming files in Perl

9. deleting, moving and renaming files in Perl

10. moving/copying files with Perl

11. move files in directories recusively in Windows using Perl

12. File::Copy::move(), directories, and NFS

 

 
Powered by phpBB® Forum Software