Hi everyone, in a directory, I have several files named something like:
Ricxxx_genomic.fna_0.97_bbmap_stats.txt
Ricxxx_genomic.fna_0.97_bs.sh
Ricxxx_genomic.fna_0.97_mapped.sam
Ricxxx_genomic.fna_0.97_mapped_sorted.bam
Ricxxx_genomic.fna_0.97_mapped_sorted.bam.bai
and i would like to change their names to:
p100e_Ricxxx_genomic.fna_0.97_bbmap_stats.txt
p100e_Ricxxx_genomic.fna_0.97_bs.sh
p100e_Ricxxx_genomic.fna_0.97_mapped.sam
p100e_Ricxxx_genomic.fna_0.97_mapped_sorted.bam
p100e_Ricxxx_genomic.fna_0.97_mapped_sorted.bam.bai
What command line can i use? I have tried the mv command but i cannot find a way to make it work on all the files at the same time. i have found the below instructions but I am not sure i am doing it correctly - how does it work in my case?:
find . -depth -name "[current file name element]" -exec sh -c 'f="{}"; mv -- "$f" "${f%[current file name element]}[new file name element]"' \;
thank you for any suggestion you can give me
thank you so much, it worked!!