Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying multiple files like *.* 1

Status
Not open for further replies.

bazcurtis

Technical User
Jul 11, 2001
134
GB
Hi,

I am running PERL on Windows 2000.

I am trying to copy every file from one folder to another. I am using - use file::copy

It works fine if I hard code a single file in the first parameter, but if I try to use *.* or one of the many other variations I have tried :) it won't work.

Does anyone know how to do this?

Any help would be much appreciated. I am new to PERL and I have to say I love it.

Best wishes

Michael
 
Hi Andy,

Thanks for your swift responce. I now have the following line and it still doesn't like it. Any idea?

chdir "$ide_unzipped"
copy (&quot;<*.ide>&quot;, &quot;$ide_path&quot;) or die &quot;can't copy files:$!&quot;;

Do I have to put in the full path for the copy or does the copy know about the chdir?


Best wishes

Michael
 
bazcurtis,
File::Copy only allows copying from one file to another. It doesn't allow multiple copies in the same call. Use File::NCopy instead.

Hope that helps.
 
My copy of PERL doesn't seem to like NCopy. it can't locate File/NCopy.pm

I am using ActivePerl v5.8.

I have found a NCopy package. Does this mean that this will be included in later version of PERL or will it always need to be downloaded as an extra?

Best wishes

Michael

 
As you are running Perl on a Windows 2000 machine try executing a system call

$copyfiles = `xcopy c:\existingdir\*.txt c:\newdir\`;
print qx/$copyfiles/;

Be careful - the ticks are NOT single quotation marks - they are backticks. These execute the resulting interpolated string as a system command

Should work! - please let me know how you get on
 
Michael,
This is an add on. You should be able to install it using ppm. eg:
Code:
ppm install File::NCopy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top