Page 1 of 1

Unable to move THE to end of file name.

Posted: 14 May 2016, 01:06
by nzdreamer55
Hi everyone,

I am trying to get the CLI of filebot on a linux setup to move the beginning word (The,A, An) to the rear of the title. I copied from this

viewtopic.php?f=5&t=211

Code: Select all

filebot -script fn:amc "/home/linux/mnt/Film.Pool/T/Test/" --def "movieFormat=/home/linux/mnt/Film.Pool/{n =~ /^(?i)[a-z]/ ? n[0] : '#'}/{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)} ({y}){' '+[vf]}/{n.upperInitial()} {' '+[vf]}{'.'+[vc]}{'.'+[ac]}{'.'+[af]}{'.'+[source]}{'.'+[group]}..."
but for some reason it deletes the file name leaving only a comma.

Any help is appreciated.

Re: Unable to move THE to end of file name.

Posted: 14 May 2016, 01:36
by rednoah
The format you think you are passing in is not the format you are actually passing in.

Hint: shell resolves your $variables before filebot is called

Re: Unable to move THE to end of file name.

Posted: 14 May 2016, 02:02
by nzdreamer55
Thanks Rednoah. I am confused by your hint.

So this is where it does not work I think.

{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}

and I am not sure why. Can you explain your hint to me? I think it has to do with the shell and the $2, $1.

Thank you very much.

Re: Unable to move THE to end of file name.

Posted: 14 May 2016, 02:47
by rednoah
There is educational value in figuring these things out by yourself. ;)

Please read this:
viewtopic.php?f=4&t=1899

Re: Unable to move THE to end of file name.

Posted: 14 May 2016, 03:16
by nzdreamer55
Thanks for the link. So from that reading I suspect that the $ (variables) need to be escaped. Am I getting warm?

So would this
{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /$2, $1/)}

need to be changed to

{n.replaceFirst(/^(?i)(The|A|An)\s(.+)/, /\$2, \$1/)}

Re: Unable to move THE to end of file name.

Posted: 14 May 2016, 04:05
by nzdreamer55
Hey that worked! Thanks for the link!