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 |
Author
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
JPGfiles that were names likeI wanted to rename them into a sequence like
001.jpg,002,jpgThis script provides the basis of the
counterrenaming thefileswith `padding applied to the numbers, resulting in: