I have files named as 0-n.jpg for n from 1 to 500, for example.
The problem is that some guy using Windows didn't use leading zeros so when I do ls I obtain
0-100.jpg
0-101.jpg
...
0-10.jpg
...
0-199.jpg
0-19.jpg
0-1.jpg
So I'd like to rename them to insert the leading zeros, so that the result of ls could be
0-001.jpg
0-002.jpg
...
0-100.jpg
...
0-499.jpg
0-500.jpg
In other words, I'd like all files with the same file name lengths.
I tried this solution but I'm getting a sequence of errors like
bash: printf: 0-99: invalid number
., but by-and., which will require some modifications to the script. How did you modify the script?echoto see the output.for f in *.jpg; do int=basename $f .jpg | cut -d '.' -f 2; echo $int; new_name=printf "e.%04i.jpg\n" $int; echo $new_name; done;