I have to rename a large number of files inside of directories (one file per directory) based on part of the parent directory's name: for example
abc_S1_R1/contig.fasta bcd_S2_R1/contig.fasta cde_S5_R1/contig.fasta
The final name I want is:
abc_S1_R1/abc.fasta bcd_S2_R1/bcd.fasta cde_S5_R1/cde.fasta
What will be the best way for me to do it? Thank you.