7

I have files which has name as following:

P50_FR_8_q2_scrolls.csv

Here the value 50 and 8 needs renaming & The results should be something like:

P21_FR_3_q2_scrolls.csv

I tired few similar to rename 's/\d{3}(\d{*})\.csv$P21_$1.csv' *.csv But no luck. (It seems I am really bad at Linux regex)

The value 50->21 and 8->3 is something that i know. But the starting value and ending value is not always in same digit size.

dinesh707
  • 185
  • 1
  • 6

1 Answers1

9

Try

rename -n 's/50(_.*)_8/21$1_3/' *.csv

The -n flag doesn't do any renaming. You can test patterns this way. Remove it for actually performing the renaming.

muru
  • 207,228