If first word is "A", "the", etc, move to end of title
Hi everyone,
I'm trying to figure out how to move the first word of a file if it's "A" or "The", etc. to the the end of the title but before the year, and add a comma and a space.
Change these:
The Untouchables (1987)
The Hateful Eight (2015)
A Quiet Place (2018)
To this:
Untouchables, The (1987)
Hateful Eight, The (2015)
Quiet Place, A (2018)
Any help would be greatly appreciated.
I'm trying to figure out how to move the first word of a file if it's "A" or "The", etc. to the the end of the title but before the year, and add a comma and a space.
Change these:
The Untouchables (1987)
The Hateful Eight (2015)
A Quiet Place (2018)
To this:
Untouchables, The (1987)
Hateful Eight, The (2015)
Quiet Place, A (2018)
Any help would be greatly appreciated.
Reply to #1:
Hey Ted,
I'm surprised you didn't use baseball movies as examples. :)
Anyway, this looks complicated but it's really quite simple. Assuming every name is followed by an open-parenthesis, this regex just takes the three words A, An and The at the start of the file and moves them to just in front of the open-parenthesis before the date.
REPLACE method:
(Lose the quotation marks)
Text to be replaced: "^(A|An|The)\b([^\(]*?)\("
Replace with: "$2, $1 ("
Occurrence: All
Case sensitive UNCHECKED
Use regular expressions CHECKED
Apply to: Name
Then go watch "Immortal: Ted Williams, The (2015)". :)
Best regards,
DF
Hey Ted,
I'm surprised you didn't use baseball movies as examples. :)
Anyway, this looks complicated but it's really quite simple. Assuming every name is followed by an open-parenthesis, this regex just takes the three words A, An and The at the start of the file and moves them to just in front of the open-parenthesis before the date.
REPLACE method:
(Lose the quotation marks)
Text to be replaced: "^(A|An|The)\b([^\(]*?)\("
Replace with: "$2, $1 ("
Occurrence: All
Case sensitive UNCHECKED
Use regular expressions CHECKED
Apply to: Name
Then go watch "Immortal: Ted Williams, The (2015)". :)
Best regards,
DF
Reply to #2:
Hi DF,
that's almost exactly what I am looking for - in my case a bit different:
I would like to move the image index P522... to the end of the file name, so that I can order the images by the meters. For this I would need a wildcard ( in the list of meta characters there is the "." for "any character"), so in this case 8 characters, 1 letter, 7 numbers.
P5220623 tag#51.JPG
P5220622 0.0m.JPG
P5220615 1.4m.JPG
P5220616 1.3m.JPG
I tried to modify the replace expression you mentioned but without success.
Any help would be very much appreciated :)
Georg
Hi DF,
that's almost exactly what I am looking for - in my case a bit different:
I would like to move the image index P522... to the end of the file name, so that I can order the images by the meters. For this I would need a wildcard ( in the list of meta characters there is the "." for "any character"), so in this case 8 characters, 1 letter, 7 numbers.
P5220623 tag#51.JPG
P5220622 0.0m.JPG
P5220615 1.4m.JPG
P5220616 1.3m.JPG
I tried to modify the replace expression you mentioned but without success.
Any help would be very much appreciated :)
Georg
Reply to #3:
Hi Georg
Try REPLACE METHOD:
TEXT TO REPLACE: (\w.*) (\w.*) add a space between the parentheses
REPLACE WITH: $2 $1 add a space after $2
Use regular expression.
Apply to Name
Miguel
Hi Georg
Try REPLACE METHOD:
TEXT TO REPLACE: (\w.*) (\w.*) add a space between the parentheses
REPLACE WITH: $2 $1 add a space after $2
Use regular expression.
Apply to Name
Miguel
Reply to #4:
Hi Miguel,
excellent, this works!
as I'm not writing code (I stopped at html), I must admit that I do not understand why the pattern (\w.*) (\w.*)
with twice the same expression does the trick.
Anyway, your rapid and competent reply saved me quite some time :) You made my Sunday afternoon!
Thanks and Best regards,
Georg
Hi Miguel,
excellent, this works!
as I'm not writing code (I stopped at html), I must admit that I do not understand why the pattern (\w.*) (\w.*)
with twice the same expression does the trick.
Anyway, your rapid and competent reply saved me quite some time :) You made my Sunday afternoon!
Thanks and Best regards,
Georg
Reply to #5:
Hi Georg,
Since my friend Miguel hasn't answered, I thought I'd try to explain.
The \w is regex shorthand for "one Word character", hence the "w". In regex, a word character is considered to be A through Z + a through z + 0 through 9 + the underscore character, so that \w matches any of those things. Another way to say it in regex is "[A-Za-z0-9_]".
Notice that the two parts of your filenames (the parts separated by the space) both start with a "word" character. The period matches any single character and the asterisk expands it to any number of characters. The space of course just matches a space, effectively separating the two parts.
There are a lot of different ways to write most expressions in regex. I suggest you just study the small section on regex in the ARen user manual (menu at top of this page) to get a better idea of the possibilities.
Best,
DF
Hi Georg,
Since my friend Miguel hasn't answered, I thought I'd try to explain.
The \w is regex shorthand for "one Word character", hence the "w". In regex, a word character is considered to be A through Z + a through z + 0 through 9 + the underscore character, so that \w matches any of those things. Another way to say it in regex is "[A-Za-z0-9_]".
Notice that the two parts of your filenames (the parts separated by the space) both start with a "word" character. The period matches any single character and the asterisk expands it to any number of characters. The space of course just matches a space, effectively separating the two parts.
There are a lot of different ways to write most expressions in regex. I suggest you just study the small section on regex in the ARen user manual (menu at top of this page) to get a better idea of the possibilities.
Best,
DF