How to rename a long list of photo filenames?

Bill Jonas bill at billjonas.com
Thu Nov 17 08:41:53 MST 2005


On Thu, Nov 10, 2005 at 10:59:21PM -0700, Ben Browning wrote:
> rename 's/porngasmica/churchtastic/' *.jpg

Thanks for pointing that out; I wasn't aware of it.  Looks like it comes
with Perl, so it should be widely available.

Looping with bash's parameter substitution is still a bit better than
how I was first doing it when I needed to do that sort of thing.

for file in pict*.jpg; do mv $file `echo $file |sed -e 's/^pict/a/'`; done

Of course, that's the most portable way doing it entirely in the shell
(for Bourne-style shells, of course).  Also handy if you find yourself
on a {proprietary,ancient} Unix without Perl installed (or without its
rename script).

-- 
Bill Jonas    *    bill at billjonas.com    *    http://www.billjonas.com/
"It's a dangerous business, Frodo, going out your front door.  You step
into the Road,  and if you don't keep your feet,  there  is  no knowing
where you might be swept off to."  --  Bilbo Baggins


More information about the PLUG-discuss mailing list