Hi I'm trying to sort some files and i'm haveing a spot of bother with part of the script.
The first time it is run a new folder is created but gives an error 'F:\temp\Test\Test14.jpg' and 'F:\temp\Test\Test14.jpg' are identical (not copied) at E:\Perl\NewDir.pl line 30
The second time creates another new folder and copies the file
Note $Old = $New for testing only hance the hard coding the actual files are in multiple folders the new folder will be based on the file name
#!/usr/bin/perl use File::Copy; use File::Path qw(make_path remove_tree); my $path = "F:\\temp\\Test" ; my $New = "F:\\temp\\Test\\Test14.jpg"; my $Old =$New; my $nFile = "Test14.jpg"; my $I=1; if (-e $New) { my $PATH = $path . $I; until (! -d $PATH) { $I++; $PATH = $path . $I; print "I'm in a loop $PATH\n"; $New = qq($PATH\\$nFile); } $path = $PATH; print "path is $path $Old $New\n" ; make_path($path); if (-d $path) { copy("$Old", "$New"); } else { print "$path not existl\n"; } }
In reply to New Folders by Brian268
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |