FileBot GUI windows 7

Any questions? Need some help?
Post Reply
User avatar
HtRabbit
Donor
Posts: 13
Joined: 09 Apr 2014, 01:18

FileBot GUI windows 7

Post by HtRabbit »

I have not been able to figure out a simple 'if' statment.
I would like to use the {collections} for movies.
i put my movies in to alpha folders and do not use the 'the'
ie Her would be in t:/H/Her/her.mkv
problem arises for collections where the movie name does not start with the same letter as the collection name
ie The Anamatrix gets put in t:/A/Matrix collection//the Anamatrix
I thought i would be a smarty pants and put in an 'if' statment
I kinda got it working :roll: but now it does not put non-collection movies in there appropriate alpha folder
I did find this code

Code: Select all

{any{collection}{n} =~ /^(?i)[a-z]/ ? n[0] : '#'}
but i cannot figure how to implement

here is the code i am using

Code: Select all

t:\new\Movies\{if ({collection}==null){n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9' : "$n0\\"};if ({collection}!=null){c0=collection.sortName().charAt(0); c0.isDigit() ? '0-9' : "$c0\\"}}{"$collection\\"}{n} [{y}]\{n} [{y}] [ID IMDB tt{imdb.imdbid}]{fn.contains('trl') || fn.contains('Trailer')|| fn.contains('trailer')|| fn.contains('TRAILER') ? '.'+'[Trailer-'+ resolution +']':""}{if (ext =~ /watched/)'.'+fn.match(/\.(avi|mkv|mp4|mov)$/)}{if (ext =~ /jpg/)'.'+fn.match(/(banner|videoimage|wide|fanart)$/)}
filebot 5-6-14.png
There is no Gravity...HST sucks!
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: FileBot GUI windows 7

Post by rednoah »

You can use this example for testing:

Code: Select all

{any{collection}{n} =~ /^(?i)[a-z]/ ? n[0] : '#'}/{collection+'/'}/{n}
And then step-by-step rebuild your format so you can figure out where you went wrong. Keep in mind that the outer most {...} define a Groovy expression, but inside the {...} will have Groovy meaning, i.e. Closure or Code Block, and the {...} have nothing to do with variable other than that variables are only available in the groovy code and not the literal parts. So things like { {collection} == null } don't make sense because you're defining a new closure which cannot be null.
:idea: Please read the FAQ and How to Request Help.
User avatar
HtRabbit
Donor
Posts: 13
Joined: 09 Apr 2014, 01:18

Re: FileBot GUI windows 7

Post by HtRabbit »

It would seem i can get one or the other, but not both
the code below will remove the 'the' and put 'the animartix' into T:\new\movies\m\the matrix collection

Code: Select all

t:\new\Movies\{def c1={c0=collection.sortName().charAt(0); c0.isDigit() ? '0-9\\' : "$c0\\"} n1={n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9\\' : "$n0\\"}; if (c1 != null) c1} {"$collection\\"}{n} [{y}]\{n} [{y}] [ID IMDB tt{imdb.imdbid}]
filebot col1.png
if i add the second if for the NON collection movies
i loose all the alpha sorting

Code: Select all

t:\new\Movies\{def c1={c0=collection.sortName().charAt(0); c0.isDigit() ? '0-9\\' : "$c0\\"} n1={n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9\\' : "$n0\\"}; if (c1 != null) c1;if (c1==null) n1} {"$collection\\"}{n} [{y}]\{n} [{y}] [ID IMDB tt{imdb.imdbid}]
filebot col2.png
There is no Gravity...HST sucks!
User avatar
HtRabbit
Donor
Posts: 13
Joined: 09 Apr 2014, 01:18

Re: FileBot GUI windows 7

Post by HtRabbit »

I feel so close, problem is that on a collection i get
T:\new\Movies\M\The Matrix Collection\A\The Animatrix [2003]
instead of
T:\new\Movies\M\The Matrix Collection\The Animatrix [2003]
what i now have is

Code: Select all

t:\new\Movies\{c0="$collection".sortName().charAt(0); c0.isDigit() ? '0-9\\' : "$c0\\"}{"$collection\\"}{n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9\\' : "$n0\\"}{n} [{y}]\{n} [{y}] [ID IMDB tt{imdb.imdbid}]
what i need is a way to check if 'collection' is empty after the {"$collection\\"}
i have tried

Code: Select all

{if (collection==null){n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9\\' : "$n0\\"}}
but it tells me that 'collection is undefined' even though i just used it
There is no Gravity...HST sucks!
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: FileBot GUI windows 7

Post by rednoah »

You can't "check collection" because it's not null, rather if you use an undefined binding it'll throw an Exception and thus break the whole expression.

I see you're not using any of my code. Use my code. The any{collection}{n} part gives you the first available binding, no matter if defined or not. So the result will be collection if collection is defined and n otherwise. So from here you can easily apply your logic and grab the first character.

From:

Code: Select all

def n0 = n.sortName().charAt(0); n0.isDigit() ? '0-9' : n0+'/'
To:

Code: Select all

def n0 = any{collection}{n}.sortName().charAt(0); n0.isDigit() ? '0-9' : n0+'/'
:idea: Please read the FAQ and How to Request Help.
User avatar
HtRabbit
Donor
Posts: 13
Joined: 09 Apr 2014, 01:18

Re: FileBot GUI windows 7

Post by HtRabbit »

so what i got working is

Code: Select all

t:\new\Movies\{def n0 = any{collection}{n}.sortName().charAt(0); n0.isDigit() ? "0-9\\" : "$n0\\"}{"$collection\\"}{n} [{y}]\{n} [{y}] [ID IMDB tt{imdb.imdbid}]{fn.contains('trl') || fn.contains('Trailer')|| fn.contains('trailer')|| fn.contains('TRAILER') ? '.'+'[Trailer-'+ resolution +']':""}{if (ext =~ /watched/)'.'+fn.match(/\.(avi|mkv|mp4|mov)$/)}{if (ext =~ /jpg/)'.'+fn.match(/(banner|videoimage|wide|fanart)$/)}
i ended up using " instead of '

Code: Select all

{def n0 = any{collection}{n}.sortName().charAt(0); n0.isDigit() ? "0-9\\" : "$n0\\"}
if i used

Code: Select all

n0+'\'
i got syntax error expecting ", found '<EOF>' and if i use

Code: Select all

"$n0\\"
everything worked

what is the diff between " and '

Thank you for your help. i really appreciate it.
also left you a donation
thanx again
There is no Gravity...HST sucks!
User avatar
rednoah
The Source
Posts: 22994
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: FileBot GUI windows 7

Post by rednoah »

"test-${1}" equals 'test-1' => i.e. a Groovy String which may contain logic
'test-${1}' equals 'test-${1}' => i.e. a simple String literal

In Strings \ is used for control characters, like \n or \r so when you want a literal \ you have to do \\ and that logic is the same for GString and simple String literals.

@see
http://groovy.codehaus.org/Strings+and+GString
:idea: Please read the FAQ and How to Request Help.
Post Reply