Moving part of filename (Newbie)

Bulk Rename Utility How-To's

Moving part of filename (Newbie)

Postby Zogarth » Mon Jun 08, 2020 8:10 am

Hello there, I have been struggling with this issue for quite a while, and really need some help.

I have a load of names that start with two consistent strings of characters, and would like to move it to the middle of it. An example:

Klassificeringsattest 2017050073_5203-3018 (B78-V59)

to

Klassificeringsattest 5203-3018 (B78-V59) 2017050073

The issue is that the titles arent consistent at all. Only the first part (Klassificeringsattest) and the second (2017050073) is semi-cosistent as they are always unbroken strings of text.

Klassificeringsattest(part 1) 2017050073(part 2)_5203-3018 (B78-V59)(Everything after part 2 into part 3)

And then swap part 2 and 3. I hope I made myself clear, and sorry as english isn't my first or even second language. Note that i dont really care if random _ or - remain.
Zogarth
 
Posts: 2
Joined: Mon Jun 08, 2020 7:55 am

Re: Moving part of filename (Newbie)

Postby RegexNinja » Mon Jun 08, 2020 10:33 am

This assumes space always separates Part1 Part2, and that underscore always separates Part2_Part3:

Regex Match/Replace:
^([^ ]+ )(\d+)_(.*)
\1\3 \2

You could omit the underscore, but since you want to remove it, its better to identify other possible separators.
For instance, to match: Part2-Part3, Part2_Part3, or Part2 Part3, you could use:
^([^ ]+ )(\d+)[-_ ](.*)
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: Moving part of filename (Newbie)

Postby Zogarth » Mon Jun 08, 2020 11:33 am

Thank you so much for the fast response. It works perfectly, and I have tested with it a bit to change it where needed. Have a nice day you absolute legend.
Zogarth
 
Posts: 2
Joined: Mon Jun 08, 2020 7:55 am


Return to How-To