Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

move files without blowing out directories

by grashoper (Monk)
on Apr 28, 2009 at 18:18 UTC ( #760694=perlquestion: print w/replies, xml ) Need Help??

grashoper has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use file:copy:recursive to move files, I want to remove the original files, but I would like to keep the directories, what did I do wrong here, the documentation for this is really confusing to me. it blew out my entire directory tree, I just want to move the files. I guess I should have used fmove but I don't understand this doc at all. can someone say this in english I don't get it, I read 3 or 4 times it doesn't make any sense all I get is blah blah blah. fcopy() This function uses File::Copy's copy() function to copy a file but not a directory. Any directories are recursively created if need be. One difference to File::Copy::copy() is that fcopy attempts to preserve the mode (see Preserving Mode below) The optional $buf in the synopsis if the same as File::Copy::copy()'s 3rd argument returns the same as File::Copy::copy() in scalar context and 1,0,0 in list context to accomidate rcopy()'s list context on regular files. (See below for more info)??
use File::Copy::Recursive; use File::Find; use File::Copy; #use strict; $Verbose; my $srcdir='c:\\inetpub\\performancetesting\\output\\new\\mlx\\'; my $destdir='c:\\mlx\\'; File::Copy::Recursive::dirmove $srcdir, $destdir or die "Copy failed: +$!"; print "done copying";

Replies are listed 'Best First'.
Re: move files without blowing out directories
by ww (Archbishop) on Apr 28, 2009 at 18:28 UTC
    I guess you should read the doc, which expands on this from the CPAN README:
    File/Copy/Recursive version 0.38 ================================ This module has 3 functions, one to copy files only, one to copy direc +tories only and one to do either depending on the argument's type.
Re: move files without blowing out directories
by ikegami (Patriarch) on Apr 28, 2009 at 18:51 UTC

    For heaven's sake, link to the docs instead of copying them minus the formatting.

    And file:copy:recursive doesn't exist. It's not even a legal module name. Why do you make us do so much work to help you?

    I think File::Copy::Recursive doesn't do what you want.

Re: move files without blowing out directories
by ramrod (Curate) on Apr 28, 2009 at 18:28 UTC
    Sounds good. Try move:
    use File::Copy; move("/dev1/fileA","/dev2/fileB");

    Update: Added link . . .
    . . . I got yelled at. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://760694]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2022-01-21 07:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?