swapping/moving filename elements

Advanced Renamer forum
#1 : 27/04-20 22:28
mud
mud
Posts: 2
Hi all,
I've been trying to see if AREN can accomplish a task and I have hit a wall.

What I want to do is this:

original filename: filename (2011) (misc text).ext

to change to.....

renamed file: (2011) filename (misc text).ext

So, if it is possible, how do I move the date "(2011)" from the middle of the filename to the beginning? The list of files has a different/varying number of characters before or after the date, so I can't just use the move command, and many of the files have more than one set of text or numbers within parenthesis, so I can't just swap using a separator. If I replace a parenthesis with a different character, they all change and I am back where I started.

I am struggling with the use of metacharacters and I don't know what i need to type in the pattern field.


27/04-20 22:28 - edited 27/04-20 22:30
#2 : 27/04-20 23:40
David Lee
David Lee
Posts: 1125
Try...
Replace: ([^\(]*)(\(\d{4}\) )
With: \2\1
Use regular expressions


27/04-20 23:40
#3 : 28/04-20 00:09
mud
mud
Posts: 2
Reply to #2:
YOU ARE AWESOME!!!!
Thank you very much, that worked!


28/04-20 00:09
#4 : 08/05-20 09:52
Hendrik Baard
Hendrik Baard
Posts: 2
Reply to #2:
Hi,
I have a large amount of e books and want to swap the authors name around

Jack Parow - Klipdrif in Cape Town
to
Parow Jack - Klipdrif in Cape Town

being an idiot I did not understand your previous explanation :(

Can you maybe help me?


08/05-20 09:52
#5 : 08/05-20 11:55
David Lee
David Lee
Posts: 1125
Use the Replace method...

Text to be replaced: (.*? )(.*? )
Replace with: \2\1
Occurrence: 1st
Use regular expressions

Check out the User Guide for an introduction to Regular Expressions (Regex):
www.advancedrenamer.com/user_guide/regular_expresions

Explanation...

In regex the metacharacter "." represents any character and the "*" modifier means match any number of repetitions of the preceding metacharacter - including zero.

Thus ".*+space" will match a substring of any length ending in a space.

However the "*" modifier is "greedy" and will match as many characters as possible so will terminate at the latest space possible. Adding the "?" reverses this behaviour and changes the "*" modifier's behaviour to "lazy", so it will terminate at the next space encountered. (Note that this feature is not described in Kim's User Guide).

Enclosing a sub-pattern in parentheses means that the match will be saved in a variable - named \1, \2 etc - that you can use in the Replace pattern.

Hence the regex (.*? )(.*? ) will match and remove the first two sub-strings ending in a space and save them in the variables \1 and \2, leaving the remainder of the filename string unchanged.

To complete the problem all you need to do is reverse the order of these variables in the replace pattern.

Hope that is clear enough to give you a start with regular expressions. They are a bit daunting a first but really very simple once you understand how they work.


08/05-20 11:55 - edited 08/05-20 11:57
#6 : 16/05-20 09:05
R.O. Roffel
R.O. Roffel
Posts: 2
Reply to #5:
Hi
I have more or less the same problem, in my ebook collection a lot of authors have two or more names beside there family name, and I got just from ebay several 1000' authors with the folder names like H G Wells, to find the author easier, it is better to have Wells, H G. How do I do that ?
I have tried the manual, but I have, as a leftover of a bad traffic accident a brain dammage and have problems now reading technical text.
Rudy


16/05-20 09:05 - edited 16/05-20 09:08
#7 : 16/05-20 09:21
David Lee
David Lee
Posts: 1125
Reply to #6:
I have already explained exactly how to do this in my detailed explanation in the previous comment (#5)!

Without the "?" modifier "*" is "greedy" - and will match as many characters as possible.

So (.*) (.*) will split the filename at the last space.


16/05-20 09:21
#8 : 17/05-20 12:33
Hendrik Baard
Hendrik Baard
Posts: 2
Reply to #5:
This is MAGIC!!!!
Thanks so much
Hendrik


17/05-20 12:33