Sort A-Z folders and add year only for movies

All about user-defined episode / movie / file name format expressions
Post Reply
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Sort A-Z folders and add year only for movies

Post by justkidding »

Hello,

I would like to sort my movies in Collections and movies according to the first letter.
For this I use the {az}-binding which is working great.
But I would like to add the year to the folder if it is a movie and if it is a collection add nothing.

e.g.

Movies/Lord of The Rings Collection/.mkv
Movies/American Hustle (2013)/.mkv

I have trouble in adding the year to the folder if it is a folder.
My movieformat looks like this at the moment:

Code: Select all

'movieFormat=/volume1/03_Filme/01 Movies/{az}/{any{collection}{n.upperInitial()}{y}}/{n.upperInitial()} ({y}) {file.path.contains('\''3D'\'') || file.path.contains('\''3-D'\'') ? '\''3D '\'':'\'\''}{file.path.contains('\''HSBS'\'') ? '\''HSBS '\'':'\'\''}{file.path.contains('\''FSBS'\'') ? '\''FSBS '\'':'\'\''} {source} {vf} {vc} {ac} {af}'
This results in
Movies/Lord of The Rings Collection/.mkv
Movies/American Hustle/.mkv

Any help is much appreciated :)
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort A-Z folders and add year only for movies

Post by rednoah »

Code: Select all

any{collection}{ny}
:idea: Please read the FAQ and How to Request Help.
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Sort A-Z folders and add year only for movies

Post by justkidding »

Awesome, thanks a lot for your fast support.
Can I also combine it with {n.upperInitial()}?

Code: Select all

any{collection}{n.upperInitial()y}
seems not to work
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort A-Z folders and add year only for movies

Post by rednoah »

Code: Select all

any{collection}{ny.upperInitial()}
:idea: Please read the FAQ and How to Request Help.
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Sort A-Z folders and add year only for movies

Post by justkidding »

works like a charm.
Thanks a lot!
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Sort A-Z folders and add year only for movies

Post by justkidding »

Sorry, I got one more question.
At the moment filebot moves the files directly in the collection folder if it is a collection.

Example:
Movies
- L
-- Lord Of The Rings Collection
--- Lord of the rings 1.mkv
--- Lord of the rings 2.mkv
etc.

For my media manager it is essential that all movies are in an own folder like this:

Movies
- L
-- Lord Of The Rings Collection
--- Lord of the rings 1
---- Lord of the rings 1.mkv
--- Lord of the rings 2
---- Lord of the rings 2.mkv
etc.

What do I have to change in my format? I can't get it to work...
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort A-Z folders and add year only for movies

Post by rednoah »

Code: Select all

{az}/{collection+'/'}{ny}/{ny}
:idea: Please read the FAQ and How to Request Help.
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Sort A-Z folders and add year only for movies

Post by justkidding »

Sorry, I don't get where to add that snippet exactly:

Neither

Code: Select all

'movieFormat=/volume1/03_Filme/01 Movies/{az}/{collection+'/'}{ny}/{ny}/{ny}/{n.upperInitial()} ({y}) {file.path.contains('\''3D'\'') || file.path.contains('\''3-D'\'') ? '\''3D '\'':'\'\''}{file.path.contains('\''HSBS'\'') ? '\''HSBS '\'':'\'\''}{file.path.contains('\''FSBS'\'') ? '\''FSBS '\'':'\'\''} {source} {vf} {vc} {ac} {af}'
works

Error:
SyntaxError: unexpected char: 0xFFFF
javax.script.ScriptException: SyntaxError: unexpected char: 0xFFFF
at net.filebot.format.ExpressionFormat.compile(ExpressionFormat.java:117)
at net.filebot.format.ExpressionFormat.<init>(ExpressionFormat.java:75)
at net.filebot.cli.CmdlineOperations.rename(CmdlineOperations.java:97)
at net.filebot.cli.ScriptShellBaseClass.rename(ScriptShellBaseClass.java:336)
at Script1$_run_closure72.doCall(Script1.groovy:399)
at Script1.run(Script1.groovy:362)
at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:62)
at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:72)
at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:114)
at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:29)
at net.filebot.Main.main(Main.java:120)

Nor

Code: Select all

'movieFormat=/volume1/03_Filme/01 Movies/{az}/{any{collection}{ny.upperInitial()}}/{collection+'/'}{ny}/{ny}/{n.upperInitial()} ({y}) {file.path.contains('\''3D'\'') || file.path.contains('\''3-D'\'') ? '\''3D '\'':'\'\''}{file.path.contains('\''HSBS'\'') ? '\''HSBS '\'':'\'\''}{file.path.contains('\''FSBS'\'') ? '\''FSBS '\'':'\'\''} {source} {vf} {vc} {ac} {af}'
works.
Error:
SyntaxError: expecting EOF, found '+'
javax.script.ScriptException: SyntaxError: expecting EOF, found '+'
at net.filebot.format.ExpressionFormat.compile(ExpressionFormat.java:117)
at net.filebot.format.ExpressionFormat.<init>(ExpressionFormat.java:75)
at net.filebot.cli.CmdlineOperations.rename(CmdlineOperations.java:97)
at net.filebot.cli.ScriptShellBaseClass.rename(ScriptShellBaseClass.java:336)
at Script1$_run_closure72.doCall(Script1.groovy:399)
at Script1.run(Script1.groovy:362)
at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:62)
at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:72)
at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:114)
at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:29)
at net.filebot.Main.main(Main.java:120)
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort A-Z folders and add year only for movies

Post by rednoah »

1. Prototype formats in the Format Editor GUI
2. Use @file syntax to pass in complicated arguments so you don't have to deal with cmdline escaping
:idea: Please read the FAQ and How to Request Help.
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Sort A-Z folders and add year only for movies

Post by justkidding »

Unfortunately, I don't have a GUI as I am using filebot on a synology NAS and Filebot Node is not working at the moment.
I have now created a args.txt file with

Code: Select all

movieFormat='/volume1/03_Filme/01 Movies/{az}/{collection+'/'}{ny}/{ny}/{n.upperInitial()} ({y}) {file.path.contains('\''3D'\'') || file.path.contains('\''3-D'\'') ? '\''3D '\'':'\'\''}{file.path.contains('\''HSBS'\'') ? '\''HSBS '\'':'\'\''}{file.path.contains('\''FSBS'\'') ? '\''FSBS '\'':'\'\''} {source} {vf} {vc} {ac} {af}'
seriesFormat='/volume1/03_Filme/02 Serien/{az}/{n}/{episode.special ? '\''Special'\'' : '\''Staffel '\''+s}/{n} - {episode.special ? '\''S00E'\''+special.pad(2) : s00e00} - {t} {vf} {ac} {af}'
In the filebotscript I have:

Code: Select all

/volume1/@appstore/filebot/filebot.sh -script 'fn:amc' --action 'test' '/volume1/downloads/Jdownloader/' --output /volume1/03_Filme -non-strict --conflict auto --lang en --def '@/volume1/03_Filme/Sorting Scripts/args.txt' 'skipExtract=y' 'subtitles=eng'  'excludeList=.excludes' --log info --log-file '/volume1/@appstore/filebot/data/root/logs/filebot.log'
Now I get the error:
SyntaxError: unexpected token: 3D
javax.script.ScriptException: SyntaxError: unexpected token: 3D
at net.filebot.format.ExpressionFormat.compile(ExpressionFormat.java:117)
at net.filebot.format.ExpressionFormat.<init>(ExpressionFormat.java:75)
at net.filebot.cli.CmdlineOperations.rename(CmdlineOperations.java:97)
at net.filebot.cli.ScriptShellBaseClass.rename(ScriptShellBaseClass.java:336)
at Script1$_run_closure72.doCall(Script1.groovy:399)
at Script1.run(Script1.groovy:362)
at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:62)
at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:72)
at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:114)
at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:29)
at net.filebot.Main.main(Main.java:120)
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort A-Z folders and add year only for movies

Post by rednoah »

1. Learn how to use FileBot formats (using the Format Editor GUI would make this much easier... just saying)
2. Learn how to use the cmdline (i.e. correctly quoting/escaping arguments)

Once you have a certain foundation, these things will become self-explanatory.

PS: You're trying to deal with (1) and (2) simultaneously, while understanding neither, so figuring things out like this will be rather tricky. I recommend doing things step by step.
:idea: Please read the FAQ and How to Request Help.
Post Reply