Aaron B. Russell’s personal blog
30 Dec
Jon,
Open a console window, type in pico ~/fnclean.pl, and paste this in:
#!/usr/bin/perl
while (<STDIN>) {
chomp($_);
$oldfilename = $_;
s/_//;
$newfilename = $_;
print "$oldfilename -> $newfilename...";
`mv $oldfilename $newfilename`;
print " done!\n";
}
Then press Control-O, hit enter, then press Control-X to save and quit pico. Then type in chmod 755 ~/fnclean.pl. Then call the program like this: ls /path/to/files/*.jpg | ~/fnclean.pl
The output will look like this:
[nanaki:~] idigital% ls /Users/idigital/*.jpg | ~/fnclean.pl
/Users/idigital/asdfkljhasdfil_73.jpg -> /Users/idigital/asdfkljhasdfil73.jpg… done!
/Users/idigital/foo_3.jpg -> /Users/idigital/foo3.jpg… done!
/Users/idigital/foo_4.jpg -> /Users/idigital/foo4.jpg… done!
/Users/idigital/foo_423.jpg -> /Users/idigital/foo423.jpg… done!
/Users/idigital/foo_42323453.jpg -> /Users/idigital/foo42323453.jpg… done!
/Users/idigital/foo_4234523453.jpg -> /Users/idigital/foo4234523453.jpg… done!
/Users/idigital/foo_4234523459783.jpg -> /Users/idigital/foo4234523459783.jpg… done!
/Users/idigital/foo_42453.jpg -> /Users/idigital/foo42453.jpg… done!
/Users/idigital/foobar_42453.jpg -> /Users/idigital/foobar42453.jpg… done!
[nanaki:~] idigital%
Enjoy.
Aaron.
7 Responses for "fnclean.pl"
Me?
*bows down and worships you*
we’re not worthy!
we’re not worthy!
we’re not worthy!
we’re not worthy!
we’re not worthy!
we’re not worthy!
we’re not worthy!
It’s after midnight….
No, the other one :p
Thank you :)
happy belated birthday!
Thank you :)
Leave a reply