Last active
September 29, 2017 13:16
-
-
Save arpitjindal97/579aeaf6db9b7f78512cce6348da7c4c to your computer and use it in GitHub Desktop.
Rename files consecutively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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