jjrogers wrote:I am not good with regular expressions, but believe it is what I need to use. I have about 5000 files named in a format similar to this:
maryborough_6594_6594_r
bundaberg_3456_3456_r
I need to remove the duplicate 6594 (or 3456) so that my filename reads
maryborough_6594_r
bundaberg_3456_r
Any help you can give would be very much appreciated.
Based on your provided examples, can we simple search for:
one-or-more chars, ==> match (\w+), store in group (1)
followed by an underscore, ==> match _
followed by one-or-more digits, match (\d+), store in group (2)
followed by an underscore, ==> match _
followed by one-or-more digits, ==> match (\d+), store in group (3)
followed by an underscore, ==> match _
followed by an "r" ? ==> match r
Then we replace only with group 1 and 2, dropping group 3.
FROM:
maryborough_6594_6594_r
bundaberg_3456_3456_r
TO:
maryborough_6594_r
bundaberg_3456_r
DO:
RegEx(1)
Match: (\w+)_(\d+)_(\d+)_r
Repla: \1_\2_r
.