mrimagepueblo
Programmer
I have a need to rename .jpg files coming in with inconsistent ending to something I can run a better if statement on in perl script I use. The front part of the filename is always consistent but the back end of the file can be anything.
I am wanting to write a shell script in #!/bin/sh to rename the files. There can anywhere from 1 to 8 .jpg files per occurence of a particular number.
1059133_124025.jpg
1059133_127329.jpg
1059133_145098.jpg
1059133_179041.jpg
1059133_134855.jpg
1059133_236549.jpg
1059133_234539.jpg
1059133_456987.jpg
1059145_170946.jpg
1059145_168902.jpg
1059145_234987.jpg
1059145_123494.jpg
1059145_232990.jpg
1059145_234380.jpg
1059145_129042.jpg
1059145_289333.jpg
I would like the files renamed keeping the front part of the filename to the _ and then incementing the back part to either _1.jpg, _2.jpg, _3.jpg,_4.jpg,_5.jpg,_6.jpg,_7.jpg,_8.jpg
or,
_a.jpg,_b.jpg,_c.jpg,_d.jpg,_e.jpg,_f.jpg,_g.jpg,_h.jpg
so the filenames would look like.
1059133_a.jpg
1059133_b.jpg
1059133_c.jpg
1059133_d.jpg
1059133_e.jpg
1059133_f.jpg
1059133_g.jpg
1059133_h.jpg
or
1059145_1.jpg
1059145_2.jpg
1059145_3.jpg
1059145_4.jpg
1059145_5.jpg
1059145_6.jpg
1059145_7.jpg
1059145_8.jpg
any help would greatly be appreciated.
I am wanting to write a shell script in #!/bin/sh to rename the files. There can anywhere from 1 to 8 .jpg files per occurence of a particular number.
1059133_124025.jpg
1059133_127329.jpg
1059133_145098.jpg
1059133_179041.jpg
1059133_134855.jpg
1059133_236549.jpg
1059133_234539.jpg
1059133_456987.jpg
1059145_170946.jpg
1059145_168902.jpg
1059145_234987.jpg
1059145_123494.jpg
1059145_232990.jpg
1059145_234380.jpg
1059145_129042.jpg
1059145_289333.jpg
I would like the files renamed keeping the front part of the filename to the _ and then incementing the back part to either _1.jpg, _2.jpg, _3.jpg,_4.jpg,_5.jpg,_6.jpg,_7.jpg,_8.jpg
or,
_a.jpg,_b.jpg,_c.jpg,_d.jpg,_e.jpg,_f.jpg,_g.jpg,_h.jpg
so the filenames would look like.
1059133_a.jpg
1059133_b.jpg
1059133_c.jpg
1059133_d.jpg
1059133_e.jpg
1059133_f.jpg
1059133_g.jpg
1059133_h.jpg
or
1059145_1.jpg
1059145_2.jpg
1059145_3.jpg
1059145_4.jpg
1059145_5.jpg
1059145_6.jpg
1059145_7.jpg
1059145_8.jpg
any help would greatly be appreciated.