#!/usr/bin/perl -w # sanerename.pl by Urchlay if($ARGV[0] eq '--fake') { shift; $fake++; } if(!@ARGV) { while(<>) { chomp; push @ARGV, $_; } } for(@ARGV) { my $o = $_; $_ = lc $_; s/(\w+)'(t|s)/${1}${2}/g; # de-apostrophize can't, don't, billy's, etc... s/\s+/ /g; s/\s-\s/-/; s/[\s`~!\@#\$%^&*()=+{}\[\]|\\;:'",<>?]/_/g; s/_+/_/g; s/_\././; s/_-_/-/g; if(-f $_) { warn "$_ already exists, not renaming `$o'\n"; } else { if($fake) { warn "$o => $_\n"; } else { rename $o, $_; } } }