#!/bin/perl -w # # Renames directories and file names to ascii readable and sane from the # garbage left behind by warez doodz # # feed with: # # # cd /dir/with/warez/in/it # # find . -type d -print -exec /usr/local/admin/warezfix.pl "{}" \; # # Reduces to lowercase and removes anything not [a-z][0-9] except forward slashes # if ($#ARGV != 0) { print "usage: warezfix.pl filename\n"; exit; } $oldname = $ARGV[0]; $newname = $oldname; # if "." or ".." exit with no error if ( $oldname eq "." ) { exit }; if ( $oldname eq ".." ) { exit }; # Do we have access? if ( -x $oldname ) { # Remove any characters that are not alphanumeric but preserve any forward slashes for directories $newname =~ s/[^a-zA-Z0-9\.\/]//g; # Convert to all lowercase $newname =~ tr/A-Z/a-z/; # If we modified the filename then rename if not exit if ( $oldname eq $newname ) { exit }; # Ok rename it... $cmd = "mv \"$oldname\" \"$newname\""; print "# $cmd\n\n"; if ( system($cmd) ) { print "warezfix.pl: rename failed for $oldname\n"; } } else { print "warezfix.pl: cannot access \'$newname\'\n"; }