I am trying to rename some files and am pretty new to regular expressions. I know how to do this the long way, but I am trying some code golf to shorten it up.
My file:
abc4800_12_S200_R1_001.fastq.gz
My goal:
abc4800_12_R1.fastq.gz
Right now I have a two-step process for renaming it:
rename 's/_S[0-9]+//g' *gz
rename 's/_001//g' *gz
But I was trying to shorten this into one single line to clean it up in one go.
I was trying to use a regular expression to skip over the parts in between, but I don’t know if that is actually a possibility in this function.
rename 's/_S[0-9]+_*?_001//g' *gz