Regular pattern in filename: how to implement?

Discussion, questions and support.
Post Reply
Message
Author
eric_verboven
Posts: 23
Joined: 27.04.2015, 15:08

Regular pattern in filename: how to implement?

#1 Post by eric_verboven » 04.12.2015, 12:35

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!

joby_toss
Posts: 1345
Joined: 22.07.2009, 21:19
Location: Romania
Contact:

Re: Regular pattern in filename: how to implement?

#2 Post by joby_toss » 04.12.2015, 15:05

Use Multi rename (Ctrl+M):

Image

eric_verboven
Posts: 23
Joined: 27.04.2015, 15:08

Re: Regular pattern in filename: how to implement?

#3 Post by eric_verboven » 04.12.2015, 15:37

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.

eric_verboven
Posts: 23
Joined: 27.04.2015, 15:08

Re: Regular pattern in filename: how to implement?

#4 Post by eric_verboven » 04.12.2015, 17:40

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.

joby_toss
Posts: 1345
Joined: 22.07.2009, 21:19
Location: Romania
Contact:

Re: Regular pattern in filename: how to implement?

#5 Post by joby_toss » 04.12.2015, 18:25

Nice job!

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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 30 guests