I want to rename multiple files in multiple directories using Bash scripting. I have 772 such directories i.e from Nishi_001 to Nishi_772. Each directory has different number of files in it but in all directories, the naming of the files is similar as follows:
sample_001samout
sample_002samout
sample_003samout
sample_004samout
.
.
sample_00Nsamout N=maximum 18
I want to rename the files in each directory to a particular name specific for each directory e.g., for Nishi_001 it contains the following files:
sample_001samout
sample_002samout
sample_003samout
to be renamed to the following format:
130906_Hiseq3A_l3_017_Dr_Nishikawa_AAGGTACA_L003_R1_001samout
130906_Hiseq3A_l3_017_Dr_Nishikawa_AAGGTACA_L003_R1_002samout
130906_Hiseq3A_l3_017_Dr_Nishikawa_AAGGTACA_L003_R1_003samout
The new name is different for each of the 772 directories. I have a file containing a list of the new names e.g
Nishi_003="130906_Hiseq3B_l7_003_Dr_Nishikawa_ATGCCTAA_L007_R1"
Nishi_004="130906_Hiseq3B_l7_004_Dr_Nishikawa_AGTGGTCA_L007_R1"
Nishi_005="130906_Hiseq3B_l7_005_Dr_Nishikawa_ACCACTGT_L007_R1"
All the files in a specific directory will all be renamed with the same name that will identify where the file came from. this new name will replace the phrase "sample" in all the files contained in that specific directory.
for example in the directory Nishi_001 the phrase "sample" in all the files should be replaced with
"130906_Hiseq3A_l3_017_Dr_Nishikawa_AAGGTACA_L003_R1"
which is the new name specific for Nishi_001 directory