Wednesday, December 14, 2011

Mass Rename Script

I need to convert bunch of files which has the same patterns and i need to do it quick, so i just created a simple bash script to help me out

LS=`ls *`
for FILE in $LS
name=`ls $FILE | cut -d . -f1`
name1=`ls $FILE | cut -d . -f3`
name2=`ls $FILE | cut -d . -f4`
mv $FILE "$name.$name1.$name2"
So, if i have a filename with and i wanted to remove the xxx part, i only need to execute the script and every file with that pattern will be changed to a.01.avi.

Simple huh? big grin BASH Rock