Moving the first x characters - 9 characters from the end

Advanced Renamer forum
#1 : 18/12-21 15:37
RB
Posts: 3
Hello All,

Wonder if someone can help me - I have tried to search through the forum, but can not find a
similar issue :-(!.

My problem is, have over a 1000 files - so doing it manually will be pain :-(.

So I have files with the following structures:

aaaaa - bbbbbbbbbb 01-01-21.txt
aaaaaaaaaa - bbbbbbbbb - ccccccc 01-01-21.txt
aaaaaaaa - bbbbb - cccc 01-01-21.txt
aa - bbbb 01-01-21.txt
aaaa - bbbbbb.txt

I want to be able to move the aaaaa's to before the date or if there is no date right
to end of the file. So they end up like this:

bbbbbbbbbb - aaaaa - 01-01-21.txt
bbbbbbbbb - ccccccc - aaaaaaaaaa - 01-01-21.txt
bbbbb - cccc - aaaaaaaa - 01-01-21.txt
bbbb - aa - 01-01-21.txt
bbbbbb - aaaa - .txt

I have tried many combinations of Move and Backwards but just can't get it to work.

I am probably doing something really stupid.

Thanks!
#2 : 18/12-21 18:16
David Lee
Posts: 1125
You need to use a Replace method with a Regular Expression...

Replace: ([^-]*- )(.*?)(( (\d{2}-\d{2}-\d{2}))|$)
with: \2 - \1\5
Use regular expressions

It was a bit tricky sorting out the nested parentheses around the date pattern in order to get the final spacing correct!
#3 : 19/12-21 03:15
RB
Posts: 3
You know, David - I hate people like you - evil geniuses. I must have spent hours trying to get this to work and you responded in hours and works perfectly!

There is no way I could have done that!

THANK YOU so much- you are a genius!!
R

#4 : 19/12-21 12:09
David Lee
Posts: 1125
Reply to #3:
Whilst it works perfectly - somehow I finished up with a redundant pair of parentheses (which just saves two copies of the unwanted string ("space + date") and the "? is unnecessary in this case.

Should have been...

Replace: ([^-]*- )(.*)( (\d{2}-\d{2}-\d{2})|$)
with: \2 - \1\4

#5 : 19/12-21 12:40
RB
Posts: 3
Hahaha I was happy with the original post - again thank you so much David!

Genius and a perfectionist - what a combination!

THANK YOU!!
R