Sunday, March 29, 2009

Bulk rename

Yesterday I wanted to rename a lot of files with the same extension (jpg actually). Knowing that linux is case-sensitive, I wanted to rename every JPG to jpg.

So the trick was to simply write
$rename -v 's/JPG/jpg/g' *.JPG

Inside quotes lies the expression that you want to replace (JPG->jpg, 2nd and 3rd argument). Outside the quotes you must give the files that this expression will work on.

Edit:
$rename -n 's/JPG/jpg/g' *.JPG
will get you to see what exactly is going to change. See here for more perl handling, or here for a more understanding way to rename stuff from terminal.

No comments:

Post a Comment