#!/usr/local/bin/perl #H# This renames all files listed on STDIN by changing all underscores to spaces. #H# Run it with something like: #H# ls|_ # print out help info if requested if ($ARGV[0] ne "") { open (SELF, $0); while () { if ($_ =~ /^#H# /) { $_ =~ s/^#H# //; print $_; } } exit; } while (<>) { $LINE=$_; chomp $LINE; $FN=$LINE; # Do a search and replace to make the new file name $FN =~ s/_/ /g; # Do the actual file rename but only if it actually needs to be changed. if ($LINE ne $FN) { print ("$LINE ==> $FN\n"); system (qq[mv "$LINE" "$FN"]); } }