It's a bad idea to use $_ for two loops at once. I don't think that's what your problem is here, but it could become a maintainability problem later.
You should check that chdir and copy succeeded before charging ahead in your loop (as already suggested by Joost).
It's always a good idea to use warnings too (though, again, I don't think that will help in this case). [Oops, as esper points out, the OP already has -w.]
#!/usr/bin/perl -w #mp3Finder.pl use strict; use warnings; use File::Copy; foreach my $dirnum (1 .. 262) { print $dirnum; my $dir = "/media/second/testdisk/linux/recup_dir.$dirnum"; print $dir; chdir($dir) or die "Can't chdir($dir): $!"; my @mp3s = glob "*.mp3"; foreach my $mp3 (@mp3s) { my $music = "/home/zack/music/$mp3"; copy($mp3, $music) or die "Can't copy $mp3 to $music: $!"; } }
In reply to Re: Trying to find and copy mp3s
by kyle
in thread Trying to find and copy mp3s
by HeyYou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |