Page 1 of 1

Regular pattern in filename: how to implement?

Posted: 04.12.2015, 12:35
by eric_verboven
Hi all,

A (hopefully) small question:

I have loads of filenames which are formed like this:
word1 word2 - something_else.txt
I would like to change them into:
word2, word1 - something_else.txt

How (and where) can I do this, i.e. switch word1 and word2, and put a comma in between?

Thanks!

Re: Regular pattern in filename: how to implement?

Posted: 04.12.2015, 15:05
by joby_toss
Use Multi rename (Ctrl+M):

Image

Re: Regular pattern in filename: how to implement?

Posted: 04.12.2015, 15:37
by eric_verboven
Thanks, Jody, but I think I wasn't sufficiently "general" in my original post. I think your method only works when you know the exact length of the things you want to switch - but I don't know that length.

Obviously, "word1" and "word2" are just placeholders. I would like to turn

Jack Jones - something1.txt
Emmanuel Williamson - somethingdifferent.txt

into

Jones, Jack - something1.txt
Williamson, Emmanuel - somethingdifferent.txt

So I suppose some regex will be required, but I don't have a clue about those things...

Any help would be very much appreciated.

Re: Regular pattern in filename: how to implement?

Posted: 04.12.2015, 17:40
by eric_verboven
Got it!
- Use "Multirename" (duh)
- Tick "Regular expression"
- in "Search for", put: ([a-z]+) ([a-z]+)
- in "Replace with", put: $2, $1

This turns
Ernest Hemingway - The Old Man and the Sea.txt
into
Hemingway, Ernest - The Old Man and the Sea.txt

Maybe it needs some finetuning, but for me it works.

Re: Regular pattern in filename: how to implement?

Posted: 04.12.2015, 18:25
by joby_toss
Nice job!

P.S. don't forget the numbers if you want your first example to work... :P
([a-z0-9]+) ([a-z0-9]+)