flieckster has asked for the wisdom of the Perl Monks concerning the following question:
and here is the same filenames with paths where to put back the images.010011510005801_0669_main.psd 010011510005801_0964_main.psd 010011520006618_0964_main.psd 010011520006618_5030_main.psd 010011520006812_0670_main.psd 010011520006812_0990_main.psd
but when i run the script below, i can't seem to chomp the paths correctly so its searching line by line. insted it is searching the entire string, and removing parts of the filename in the paths. see below 010011510005801, should be 010011510005801_0669_main.psd/Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/4/01001 +1510005801_0669_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/4/01001 +1520006618_5030_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/4/01001 +1520006812_0670_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/9/01001 +1510005801_0964_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/9/01001 +1520006618_0964_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/9/01001 +1520006812_0990_main.psd
010011510005801_0669_main.psd /Volumes/photorepos/Partners/Christopher_Banks/post/CB_instock/4/01001 +1510005801/Volumes/photorepos/Partners/Christopher_Banks/post/CB_inst +ock/4/010011520006618/Volumes/photorepos/Partners/Christopher_Banks/p +ost/CB_instock/4/010011520006812/Volumes/photorepos/Partners/Christop +her_Banks/post/CB_instock/9/010011510005801/Volumes/photorepos/Partne +rs/Christopher_Banks/post/CB_instock/9/010011520006618/Volumes/photor +epos/Partners/Christopher_Banks/post/CB_instock/9/010011520006812_099 +0_main.psd
#!/usr/bin/env perl -w use File::Find; use File::Copy; use File::Basename; use File::Basename; use File::Slurp; use POSIX qw(strftime); my $date = strftime("%m-%d-%y",localtime); my $time = strftime("%I:%M:%S",localtime); my $findme = "/Volumes/photorepos/Perl/SLAperlDropback/"; my $file_loc = $findme. '2SLAday'; my $filenames_to_putback = '/Volumes/photorepos/Perl/SLAperlDropback/d +ropback.txt'; chdir($file_loc) or warn "$!"; @filesforeach = glob "*.*"; my $filecount = @filesforeach; print "$filecount\n"; chomp @filesforeach; foreach $file (@filesforeach){ print "$file\n"; open(my $fh, "<", "$filenames_to_putback") or warn "$!\n"; while (my $row = <$fh>) { chomp $row; print "$row\n"; my @line = $file; for (@line) { if ($_ =~ /$row/) { chomp $_; # push @output, "found $_ that matched redo $file $row <br>"; move($_,$row) or warn "shit went wrong yo! $!\n"; } } } } # print "@output\n";
|
---|