bibliophile wrote:Thank you for your assistance!
I need help converting the following (using a real life example this time)
SCENARIO ONE:
FROM: Moby Dick - Herman Melville
TO: Herman Melville - Moby Dick
SCENARIO TWO:
FROM: Moby Dick - Melville, Herman
TO: Herman Melville - Moby Dick
SCENARIO THREE:
FROM: Moby Dick, Melville Herman
TO: Herman Melville - Moby Dick
I have already separated the files for each scenario in their own folder. Now I just need help creating the Regex formula for each scenario above.
Any assistance you can offer would be greatly appreciated. Thanks again.
Ahh, that are already the remain 30%? Now i get it too.
>>"using a real life example this time"
And you have no extension

But well done at least that you have now provided two word "Title"
SCENARIO ONE:
FROM:
Moby Dick -
Herman Melville.ext
TO:
Herman Melville - Moby Dick.ext
USE:
"Options > Ignore... > [ ]File Extensions" not checked
RegEx(1)
Match: "(.+) - (.+)"
Repla: "\2 - \1"
Explanation:
Match everything till space-hyphen-space and store it in group 1.
Then match the rest and store it in group 2.
On replacement exchange the order of those groups and add space-hyphen-space again yourself.
#########################################
SCENARIO TWO:
FROM:
Moby Dick - Melville,
Herman.ext
TO:
Herman Melville - Moby Dick.ext
USE:
"Options > Ignore... > [ ]File Extensions" not checked
RegEx(1)
Match: "(.+) - (.+), (.+)"
Repla: "\3 \2 - \1"
Explanation:
Match everything till space-hyphen-space and store it in group 1.
Then match everything till comma-space and store it in group 2.
Then match the rest and store it in group 3.
#########################################
SCENARIO THREE:
FROM:
Moby Dick, Melville
Herman.ext
TO:
Herman Melville - Moby Dick.ext
USE:
"Options > Ignore... > [ ]File Extensions" not checked
RegEx(1)
Match: "(.+), (.+) (.+)"
Repla: "\3 \2 - \1"
Explanation:
Match everything till comma-space and store it in group 1.
Then match everything till a space and store it in group 2.
Then match the rest and store it in group 3.
#########################################
HTH?

Note:
the provided regex will work well only for two word parts.
Some of then will not work as expected for file names like "The Bar None Ranch - Asprin, Robert Lynn.ext"
But then again that was not the question anyway, isn't it?