in reply to How can I opendir, replace all files containing a space with .?

Hmm. Be careful with this script (once corrected) - if you have two files "legalise cannabis" and "legalise.cannabis", the first file will be renamed on top of the second one!

I'd change the middle of your loop to:

if (-e $newfile) { print STDERR ("Warning: $filename would " ."clobber $newfile, skipping\n"); } else { rename($filename, $newfile); }
  • Comment on Re: How can I opendir, replace all files containing a space with .?
  • Download Code