EDIT: My original goal was to use Regular Expressions in Pro Tools' "Batch Rename" dialogue. Regular Expressions in Pro Tools doesn't support something as specific as this. The question has shifted to how to achieve the following by batch renaming files in Finder using an Automator app with the Run Shell Script command.
Original question:
I'd like to batch rename many items in a program that supports batch renaming using regular expressions (Pro Tools). What do I need to enter in the "Find" and "Replace" fields to replace all text proceeding _rr
with sequential numbering (1, 2, 3, etc.) that restarts every time the string preceeding _rr
changes?
I've gotten as far as Find: _rr(.*)
, but I can't figure out how to create a number sequence that restarts based on preceding text patterns/changes.
For a concrete example, take this set of data:
Casio AA_12_Test_A3_rr_01-03
Casio AA_12_Test_A3_rr_01-04
Casio AA_12_Test_A4_rr_01-03
Casio AA_12_Test_A4_rr_01-05
Casio AA_12_Test_A4_rr_01-06
Casio AA_12_Test_B5_lng_rr_01-04
Casio AA_12_Test_B5_lng_rr_01-05
Casio AA_12_Test_B5_sht_rr_01-02
Casio AA_12_Test_B5_sht_rr_01-05
Casio AA_12_Test_E4_sht_rr_01-02
Casio AA_12_Test_E4_sht_rr_01-07
Casio AA_12_Test_E5_sht_rr_01-04
Casio AA_12_Test_E5_sht_rr_01-05-01
Casio AA_12_Test_F5_lng_rr_01-05
Casio AA_12_Test_G4_lng_rr_01-04-01
What regular expression would yield the following?
Casio AA_12_Test_A3_rr1
Casio AA_12_Test_A3_rr2
Casio AA_12_Test_A4_rr1
Casio AA_12_Test_A4_rr2
Casio AA_12_Test_A4_rr3
Casio AA_12_Test_B5_lng_rr1
Casio AA_12_Test_B5_lng_rr2
Casio AA_12_Test_B5_sht_rr1
Casio AA_12_Test_B5_sht_rr2
Casio AA_12_Test_E4_sht_rr1
Casio AA_12_Test_E4_sht_rr2
Casio AA_12_Test_E5_sht_rr1
Casio AA_12_Test_E5_sht_rr2
Casio AA_12_Test_F5_lng_rr1
Casio AA_12_Test_G4_lng_rr1