Created
December 12, 2024 10:13
-
-
Save chenghanc/89f460062e65fecf3494ad1fea9caff9 to your computer and use it in GitHub Desktop.
Renaming files in a folder to sequential numbers
This file contains hidden or 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
| # jpg files | |
| a=1 | |
| for i in *.jpg; do | |
| new=$(printf "%04d.jpg" "$a") | |
| mv -i -- "$i" "$new" | |
| let a="$a+1" | |
| done | |
| # xml files | |
| a=1 | |
| for i in *.xml; do | |
| new=$(printf "%04d.xml" "$a") | |
| mv -i -- "$i" "$new" | |
| let a="$a+1" | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Renaming files in a folder to img + sequential numbers