Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Moving files and directories

by bichonfrise74 (Vicar)
on May 09, 2009 at 00:03 UTC ( [id://762973]=note: print w/replies, xml ) Need Help??


in reply to Moving files and directories

Just out of curiosity, what happens when you pass an actual file? Eg.
my $inDir = "M:\AllFiles\test.txt"; my $outDir = "n:\allFiles\abc.txt";
And I would guess that you need to read each size of your files in your directory and then add them up.

Replies are listed 'Best First'.
Re^2: Moving files and directories
by perlNinny (Beadle) on May 09, 2009 at 00:28 UTC
    Ask and ye shall receive
    With this code:
    use strict; use warnings; use File::Copy; # yes, it is Windows XP and a drive letters assigned to a USB and a NA +S drive. # Indir and outdir will be a parameter in this format. my $inDir = "M:\\AllFiles"; my $outDir = "n:\\allFiles"; # test 1 straight in out in DOS format. MoveFiles($inDir,$outDir); $inDir = "M:\\AllFiles\\TestDoc.txt"; $outDir = "n:\\allFiles\\abc.txt"; # test 2 Try specific files. MoveFiles($inDir,$outDir); $inDir = "M:\\AllFiles"; $outDir = "n:\\allFiles\\"; # test 3 Try selecting ALL files in the directory MoveFiles($inDir."\\*", $outDir); sub MoveFiles { my ( $source, $destination ) = @_; print "indir= $source, outdir=$destination\n"; my $source_size = (-s $source) || 0; my $destination_size = (-s $destination) || 0; move( $source, $destination ); print "indir size=$source_size outdir size=$destination_size\n"; }
    indir= M:\AllFiles, outdir=n:\allFiles
    indir size=0 outdir size=0
    indir= M:\AllFiles\TestDoc.txt, outdir=n:\allFiles\abc.txt
    indir size=18 outdir size=0
    indir= M:\AllFiles\*, outdir=n:\allFiles\
    indir size=0 outdir size=0
    I get the abc.txt in the n:\allfiles but the rest are left in the m:\Allfiles directory.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found