in reply to Renaming Every File in a directory

Make backups of your server directories.

Re-read the documentation for the File::Find module.

Remember to use fullpaths, with/or the $File::Find::dir var, examine the chdir no_chdir flags. Do some extensive testing pre-production run, to ensure your routine does what you want it to do / think it does.

my $count = 1; sub do_this{ ... next unless $_ =~ m/(.*)(\.jpg)$/; # untaint = $1,$2 # rename(OLDFILE, NEWFILE); rename($File::Find::dir.$1.'.jpg', $File::Find::dir.$count++.'.jpg'); }

Also IIRC you will want to next rather than return inside the &do_this routine.


Scavenging Leftovers since the Naughties