I have sets of binary files named with the extension .db1 (= ending
with the numeral one). The first parts of the file names have the
structure: name_A01, name_B01, name_C01, ..., name_L01. The files
come in sets of 12 (=A-L), and there are 12 sets (01-12). (The second
set would be name_A02, name_B02, name_C02, ..., name_L02.) The "name"
part is variable in length and consists of letters, numerals, the
underscore character, the dot character and hyphens. I would like a
Perl (v.5 or higher) script to rename the files in sequence by
prepending three digit numbers to the front of each existing file
name, from 1 to 144. The file names would then range from
001_name_A02.db1 to 144_name_L12. My intention is to have a script I
can place in a folder of target files, run the script, and have the
files renamed. There will be cases where certain files of the 144
file series will be missing in a target set. I would like the script
to process all files present and will not need any messages indicating
skipped files. Should your answer involve 144 repetitive lines, where
the structure is the same but only the obvious parts of the file name
change, you need not type that out, just indicate the form clearly and
I will fill it in. I will check back for answers in a few days.
Here are 3 sample original file names:
AS3_4-2c_CanefU_A01.db1
AS3_4-4d_CanefU_D02.db1
Brown_max.PLUS.1398F_F11.db1
The desired edited names:
001_AS3_4-2c_CanefU_A01.db1
016_AS3_4-4d_CanefU_D02.db1
126_Brown_max.PLUS.1398F_F11.db1 |