Tag Archives: tip

Renaming Files Sequentially with BASH

I made a cool one-liner in bash today that renames files sequentially. Here’s an example that takes all the JPEGs in a directory and renames them in order:


EII=4; for i in *.jpg; do ls $i; \
NEWNAME=IMG_00`printf "%02d" $EII`.JPG; \
echo Renaming $i to $NEWNAME; \
mv $i $NEWNAME; EII=`expr $EII + 1`; done

Pretty cool, huh? This is in relation to my next post. Keep watch…