Hello everyone,
I have cobbled together a naming scheme from other peoples suggestions. If I have the word The, A, or An in the beginning, I like to have it be at the end of the title after a coma (for example the big lebowski => big lebowski, the) I was using {n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)} to do this, but sometimes filebot will put the files into a folder called $2, $1 and I am not sure why. Here is what I think is happening
n = name
replaceFirst is the command to replace the first word it finds
Not sure about the ^(?i)
(The|A|An) are the things it is looking for to replace
\s(.+) not sure
and don't know what the $2, $1 is for but I think it is the pattern that gets filled in from the first part of the command.
I only get a little of the regex so any help would be appreciated.
Thanks
help with {n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)}
-
- Posts: 168
- Joined: 20 Jul 2012, 23:25
-
- Posts: 168
- Joined: 20 Jul 2012, 23:25
Re: help with {n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)}
Should it maybe
{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
Re: help with {n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)}
tip #1 Read up on Regular expression
test out here: https://regexr.com/
btw: I think this is better:
e.g. output: Movie, The (2020)
vs
e.g. output: Movie (2020), The
Regular expression:
test out here: https://regexr.com/
btw: I think this is better:
Code: Select all
{ny.replaceFirst(/^(?i)(The|A|An)\s((?:.+(?=.+\(\d{4}))|(?:.+))/, /$2, $1/)}
vs
Code: Select all
{ny.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}
Regular expression:
(abc) capture group
\1 backreference to group #1 ($1 in Filebot)
. Dot. Matches any character except line breaks.
+ Quantifier. Match 1 or more of the preceding token.
Re: help with {n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)}
Just using n.sortName() is an easy option.