Last active
September 12, 2023 02:05
-
-
Save devraj/682f45462fb7713920c543bf11fd880b to your computer and use it in GitHub Desktop.
Takes the contents a folder and renames them into filenames with sequential file names e.g 001.jpg, 002,jpg
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
let counter=1;\ | |
for filename in *; do\ | |
new_filename=$(printf "%03d.png" $counter);\ | |
print "$filename -> $new_filename";\ | |
let counter=counter+1;\ | |
mv "${filename}" $new_filename;\ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was working on a site for a friend who's a photographer and provided me with a set of
JPG
files that were names likeI wanted to rename them into a sequence like
001.jpg
,002,jpg
This script provides the basis of the
counter
renaming thefiles
with `padding applied to the numbers, resulting in: