Shell Script Mass Change filename (Rename pattern file)

** Myself

#Create 10,000 file from CCC00001.JPG to CCC10000.JPG
#file name=CCC00001.JPG ,CCC00002.JPG .... 
mkdir -p /tmp/test
for i in {1..10000}
do
 touch /tmp/test/CCC`printf "%05d" $i`.JPG
done


#Rename 10,000 file from CCC00001.JPG to A00001.JPG
#Result file name=A00001.JPG ,A00002.JPG .... 

for T in *.JPG
do
U=$(printf $T | sed -e "s/CCC/A/g")
[[ $T != $U ]] && mv $T $U
done

0 comments:

Loading