Help with swapping part of filename - kinda tricky

Advanced Renamer forum
#1 : 18/09-18 07:15
L B
L B
Posts: 11
I have a lot of filenames in this format:

X.Y_A.date.P.Q.R.S-T

date is of the format 18.09.23, for example

I want to swap the positions of date and A without affecting the rest of the file name.

As you can see the separator in this instance is "." which is all too common across the file name.

The X.Y_ portion is a constant, and A can be variable length.

Please help.


18/09-18 07:15
#2 : 18/09-18 11:14
David Lee
David Lee
Posts: 58
Assuming that none of the components of your filename contain any "Word separators" (by default: .,_-()[]{}! but editable in Settings) then you can use the New Name method with the string: "<Word:1>.<Word:2>_<Word:4>.<Word:5>.<Word:6>.<Word:3>.<Word:7>" - applied to Name only.


18/09-18 11:14
#3 : 18/09-18 13:14
L B
L B
Posts: 11
Reply to #2:

It works, as in it inverts the date and the string before it, but is there a way to treat the trailing part of the filename as a single string? (the P.Q.R.S-T part)

Its not always 4 words exactly, it can be P.Q-T or P.Q.R.S.U-T, etc.


18/09-18 13:14 - edited 18/09-18 13:15
#4 : 18/09-18 16:01
David Lee
David Lee
Posts: 58
Try this regular expression:

Replace Method
Text to be replaced: "(.*)_([^.]*).(.{8}).(.*)"
Replace with: "\1_\3.\2.\4"
Tick "Use regular expressions"



18/09-18 16:01
#5 : 18/09-18 18:23
L B
L B
Posts: 11
Reply to #4:

Dude, perfect! Thanks!

I really should to get into reg-ex. Such an elegant solution (although I didn't understand a thing).


18/09-18 18:23
#6 : 19/09-18 09:21
Kim Jensen
Kim Jensen
Administrator
Posts: 804
Reply to #5:
Regular expressions are great but are difficult to learn. Even programmers can have a hard time understanding regular expressions.

I have tried to make a simple introduction to regular expressions:
https://www.advancedrenamer.com/user_guide/regul ar_expresions

You might also find good resources online by searching google.


19/09-18 09:21