0

I have a bunch of file names like this a1_b2_c3_d4.png but I want them to renamed like this a1_b2_d4_c3.png. I am having NameChanger application to implement regex on file names. I could not figure out regex to swap c3 and d4. If anyone can help me with the regex, that will be great.

Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397
Stu M
  • 19
  • 5

1 Answers1

0

There are three permutations to what you ask:

  1. If you only care about the last 2 before the dot

find ([^._]+)_([^._]+)\.
replace $2_$1.

  1. If it has to be exactly the 3 rd or 4 th before the dot

find ^([^._]+_[^._]+_)([^._]+)_([^._]+)\.
replace $1$3_$2.

  1. If it has to be exactly the 3 rd or 4 th without dot

find ^([^._]+_[^._]+_)([^._]+)_([^._]+)
replace $1$3_$2