Unable to move THE to end of file name.

All about user-defined episode / movie / file name format expressions
Post Reply
nzdreamer55
Posts: 168
Joined: 20 Jul 2012, 23:25

Unable to move THE to end of file name.

Post 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.
User avatar
rednoah
The Source
Posts: 23935
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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
:idea: Please read the FAQ and How to Request Help.
nzdreamer55
Posts: 168
Joined: 20 Jul 2012, 23:25

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

Post 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.
User avatar
rednoah
The Source
Posts: 23935
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah »

There is educational value in figuring these things out by yourself. ;)

Please read this:
viewtopic.php?f=4&t=1899
:idea: Please read the FAQ and How to Request Help.
nzdreamer55
Posts: 168
Joined: 20 Jul 2012, 23:25

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

Post 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/)}
nzdreamer55
Posts: 168
Joined: 20 Jul 2012, 23:25

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

Post by nzdreamer55 »

Hey that worked! Thanks for the link!
Post Reply