by Glenn » Wed Apr 01, 2015 8:57 pm
When you have a situation where you are dealing with variable length words, the best course of action is to use wildcards, and in this case a regular expression should fit the bill. Although it would be possible to move every first word to the back before the first hyphen, it's probably safest to do these in groups e.g. All the "the"'s, then all of the "a"'s, etc.
So, in the RegEx(1) Match box put
The (.*?)( -.*)
"The " means literally match any filename starting with "The" followed by a space
(.*?) means match any series of characters - the "." means any character, the "*" means zero or more times, the "?" means don't be greedy.
This is saved as \1 (any time you surround a match sequence with parentheses, these are captured to use in the replacement and are numbered in order of appearance in the match line \1, \2, \3 ...etc.)
( -.*) means match a space followed by a hyphen followed by any series of characters, basically the rest of the line.
This is saved as \2
If we hadn't used the ? in the first grouping to turn off greediness, the first group would have matched the all the way to the last hyphen and would have made the split in the wrong place. i.e. ".*" will match the whole line first, then backtrack until the ( -.*) also matches which will be the last hyphen.
And in the Replace put
\1, The\2
That will replace all the "The"'s. To shift a leading "A", simply replace the "The" in the above with an "A".
Do the same for any other leading word you want.
Cheers,
Glenn