Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: copy files to another directory

by martymart (Deacon)
on Feb 19, 2003 at 10:19 UTC ( [id://236591]=note: print w/replies, xml ) Need Help??


in reply to copy files to another directory

Hi, seems a bit complicated for just doing a copy function, why not try, something like this:
#! usr/bin/perl -w use File::Copy; my @list = <C:\LOCATION\*.rtf>; foreach my $file(@list){ copy ($file,"C:\Temp\"); }
However, if you wanted to save on the typing you could use a system call (DOS version shown below, I think this'll probably be slower though), you could write this like:
#! usr/bin/perl -w system ("copy /y LOCATION\\*.rtf C:\Temp");
this just uses a DOS copy command (the /y is just so that you're not prompted when a file is being overwritten)
Regards
Martymart

Replies are listed 'Best First'.
Re: Re: copy files to another directory
by jasonk (Parson) on Feb 19, 2003 at 14:19 UTC

    I would suggest not doing something like this, for the following reasons:

    #! usr/bin/perl -w # missing a /, although it doesn't matter on DOS use File::Copy; my @list = <C:\LOCATION\*.rtf>; # You seem to be looking for files named 'LOCATION*.rtf', # which probably doesn't exist, putting a backslash in # front of the * makes it a literal *, it isn't a glob # anymore, and I'm not sure what \L will get you, but it # probably won't be the letter L. foreach my $file(@list){ copy ($file,"C:\Temp\"); # \t is a tab, this will fail, unless you actually # have a directory called 'C:(tab)emp', read perlfaq5 # and always use forward slashes, even in dos }

    As for the dos version, it doesn't even really contain any perl, just put the copy command in a batch script.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found