RegEx help needed - Insert a dash (-) between two words

Advanced Renamer forum
#1 : 30/12-18 02:50
L B
L B
Posts: 50
I have a lot of folders with the general format of

<Country> - <Date> - <City> <Venue> - <No of Pics> <Resolution>

What I wanna do is insert a dash (-) between City and Venue, but the issue is how to do this in bulk for all folders. Currently, I have a Replace Method with regex enabled where I manually enter the city names separated by the OR sign (|) :

Text to be replaced = (Canberra|Taipei|Kuala Lampur|Bali|Mumbai)(\s?)
Replace with = \1 -

But given the number of various cities (50+), this is proving to be long and tedious. Is there a way to construct a general query where I don't need to enter each city name manually? City names are either a single word (Mumbai) or 2 words (Kuala Lampur) and come directly after <Date>, whereas the Venue can be one or many words and end directly before the <No of Pics>.

EDIT: Please Read Reply


30/12-18 02:50 - edited 30/12-18 03:52
#2 : 30/12-18 03:28
L B
L B
Posts: 50
Reply to #1:

UPDATE: OK...writing this post had a "rubber duck debugging" effect 🤷‍♂

I was able to construct two Replace Methods to tackle One-Word and Two-Word City names separately, as follows:

1-Word City:
---------------
Text to be Replaced = (\d\d) - (\w+) (.*) - (x\d+)
Replace With = \1 - \2 - \3 - \4

2-Word City:
---------------
Text to be Replaced = (\d\d) - (\w+ \w+) (.*) - (x\d+)
Replace With = \1 - \2 - \3 - \4

I suppose I will just have to rename 1-word and 2-word cities in separate go-arounds, but its still better than entering 50 cities manually in the method.

Now my issue is with Folders where the <City> part has multiple cities (2 or more), separated by either a comma or an ampersand or the word "and", or a combination thereof.

Example: Sri Lanka - 2005-06-07 - Negombo, Colombo & Galle Train Ride - x32 3000px

Here, <City> is "Negombo, Colombo & Galle" and <Venue> is "Train Ride".

This example contains 3 cities but there are folders with 6 or more cities.

No idea how to construct this query.

EDIT: Please read next reply.


30/12-18 03:28 - edited 31/12-18 05:39
#3 : 31/12-18 05:39
L B
L B
Posts: 50
Reply to #2:

Hmm, I did this, although I have to test it more.

Multiple Cities End in 1-WORD City
---------------------------------------
Text to be Replaced = (\d\d) - (.*)(&|\,|and) (\w+) (.*) - (x\d+)
Replace With = \1 - \2\3 \4 - \5 - \6

Multiple Cities End in 2-WORD City
---------------------------------------
Text to be Replaced = (\d\d) - (.*)(&|\,|and) (\w+ \w+) (.*) - (x\d+)
Replace With = \1 - \2\3 \4 - \5 - \6

But now my issue is that there are FOUR different Replace Methods to perform the same task, and they cannot be turned on at the same time, which means I have to make four passes, each time deselecting and selecting the folders that match the criteria.

So, I ask those here who are better at ARen and RegEx than me:
Is there a better way, a more streamlined way to achieve this than to create 4 separate methods?

Please help.


31/12-18 05:39