Currently the file below renames files by changing spaces to underscores.
usage:
find | ./file_name_fixer.pl
how could it be shortened up?
I would eventually like to modify it so that it will will modify names
so that they only contain 'a-z0-9._'
thanks.
#!/usr/bin/perl
while (<>)
{
chomp;
unless (-e $_)
{
print "$_ <=== does not exist\n";
next;
}
$oldname = $_;
s/ /_/;
if ($oldname eq $_)
{
next;
}
if (-e $_)
{
print "$_ <=== already exists\n";
next;
}
print "renaming $oldname ===> $_\n";
rename $oldname, $_;