
Laurent_R
Enthusiast
Feb 11, 2013, 2:35 PM
Post #2 of 5
(217 views)
|
|
Re: [bill1234] Copying files from one directory to another
[In reply to]
|
Can't Post
|
|
You give too little information. Assuming you are on Unix and want to copy all *.wav files from the ./old/ to the ./new/ directory, try something like this (quick code, untested):
#!/usr/bin/perl use strict; use warnings; use File::Copy; my @file_list = glob ("./old/*.wav"); chomp @file_list; foreach my $old_file (@file_list) { my $new_file = $old_file; $new_file =~ s{/old/}{/new/}; # these two code lines could be made into one, but it is probably clearer this way for a beginner print "copying $old_file to $new_file \n"; # useless for the program, just information displayed to the user (may also help debugging) copy ($old_file, $new_file) or die "File $old_file cannot be copied to $new_file $! \n"; } Just change your file paths to what you need, whether on Unix, Windows or whatever.
|