Skip to content

Instantly share code, notes, and snippets.

@arpitjindal97
Last active September 29, 2017 13:16
Show Gist options
  • Save arpitjindal97/579aeaf6db9b7f78512cce6348da7c4c to your computer and use it in GitHub Desktop.
Save arpitjindal97/579aeaf6db9b7f78512cce6348da7c4c to your computer and use it in GitHub Desktop.
Rename files consecutively
count=1
if [ ! -d "temp1" ];then mkdir temp1; fi
for i in *;
do
if [ -f "$i" ];
then
ext=$(echo "$i" | awk -F"." '{print $NF}')
mv "$i" "temp1/img_$count.$ext";
count=$(expr $count + 1)
fi
done
mv temp1/* .
rm -r temp1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment