#!/usr/bin/perl use File::Copy; # repair # jody DeRidder, 8/28/09 # goes through /srv/www/htdocs/content # finds jpg files with -1.jpg and -0.jpg # renames the -0 ones, removing the -0, and # deletes the -1 files $inbase = "/srv/www/htdocs/content/"; push (@dirlist, $inbase); foreach $dir (@dirlist){ opendir (DIR, $dir) or die "can't look through $dir\n"; while ($file = readdir(DIR)){ # print "looking at $file in $dir\n"; if ($file =~ /^\./ ){ next; } # skip dot files $path = $dir."/".$file; if ( -d $path){ # must be a directory push (@dirlist, $path); } elsif ($file =~ /^(.*)\-1\.jpg/){ # jpg file `rm $path`; } elsif ($file =~ /^(.*)\-0\.jpg/){ $filenum = $1.".jpg"; $good = $dir."/".$filenum; `mv $path $good`; } } }