Created
February 1, 2022 16:23
-
-
Save rileyjshaw/85be6d9ab4b4c84436527df4b9651428 to your computer and use it in GitHub Desktop.
Rename files to `01.ext`, `02.ext`, etc. based on output order of `ls`
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
#!/bin/bash | |
FILES=($(ls -tUr *.{png,jpeg})) | |
for i in "${!FILES[@]}"; do | |
mv "${FILES[i]}" "$(printf "%02d.${FILES[i]##*.}" "$((i + 1))")" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment