Sort movies by year range (e.g. 1900-1999)

All about user-defined episode / movie format expressions
Post Reply
Frederiklol
Posts: 9
Joined: 18 Feb 2017, 19:06

Sort movies by year range (e.g. 1900-1999)

Post by Frederiklol »

Hi,

I have been using a rather unusal folder structure for my movies.
Which is like this
/Movies/1900 - 1999
/2000 - 2010
/2011
/2012
And so forth.. :roll:

So, the AMC script are actually working fine for newer movies. But Filebot creates new folders for older movies like 1995(Which make sense, as my script indicates it should do that, i am aware)

But is there any expression i could use to format that to fit my actual needs? I cant seem to figure out how to say movies from 19xx ->(go to) that exact folder.
Have a great weekend :D
User avatar
rednoah
The Source
Posts: 19015
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort movies by my broken organization

Post by rednoah »

That's a cute use case. A simple if-then-else will get job done:

Code: Select all

{y > 2010 ? y : y > 1999 ? '2000-2010' : '1900-1999'}
:idea: Please read the FAQ and How to Request Help.
Frederiklol
Posts: 9
Joined: 18 Feb 2017, 19:06

Re: Sort movies by year range (e.g. 1900-1999)

Post by Frederiklol »

I completely forgot about this.

You are a wizard for us "noobs".

It worked flawlessly, in first try.

Thank you once again!!
Frederiklol
Posts: 9
Joined: 18 Feb 2017, 19:06

Re: Sort movies by year range (e.g. 1900-1999)

Post by Frederiklol »

While i am at it.. Im trying to cut from 2 scripts to 1..

Is it possible to make filebot try to match a collection
Like this;

Code: Select all

 {any{'Movie Collections/'+collection}{'Movie'}}/{ny}) 
But if no match for collection is found then use

Code: Select all

 {y > 2010 ? y : y > 1999 ? '2000 - 2010' : '19xx - 1999'}/{ny}/{ny} 
Cant seem to figure out if that is possible. Right now i am using two scripts to seperate..
User avatar
rednoah
The Source
Posts: 19015
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort movies by year range (e.g. 1900-1999)

Post by rednoah »

Sure:

Code: Select all

any{"Movie Collections/$collection"}{"${y > 2010 ? y : y > 1999 ? '2000 - 2010' : '19xx - 1999'}/Movies"}
:idea: Please read the FAQ and How to Request Help.
Frederiklol
Posts: 9
Joined: 18 Feb 2017, 19:06

Re: Sort movies by year range (e.g. 1900-1999)

Post by Frederiklol »

Thank you for the reply.

Unfortunately i am not that great with expression, format and anything in between, BUT!

I got it to work with some modifications, this is how it looks(Used the -action test)

Code: Select all

 "/volume1/Media/Test/{any{'Collections/'+collection}{y > 2010 ? y : y > 1999 ? '2000 - 2010' : '19xx - 1999'}}/{ny} {vc}-{vf} {source}{'.'+lang}" 
Thank you once again!
User avatar
rednoah
The Source
Posts: 19015
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Sort movies by year range (e.g. 1900-1999)

Post by rednoah »

I was using "..." in the format, so on the command-line you'd have to escape that correctly because "..." already has special meaning.

:idea: Use the @file syntax for reading command-line arguments from external text files so you don't have to worry about command-line argument parsing.
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 97
Joined: 12 Apr 2020, 04:02

Re: Sort movies by year range (e.g. 1900-1999)

Post by AbedlaPaille »

Code: Select all

{ 
 y > 2019 ? '2020' 
	  : y > 2014 
	  ? '2015-2019' 
	  : y > 2009 
	  ? '2010-2014' 
	  : y > 2004 
	  ? '2005-2009' 
	  : y > 1999 
	  ? '2000-2004' 
	  : y > 1989 
	  ? '1990-1999' 
	  : y > 1979 
	  ? '1980-1989' 
	  : y > 1969 
	  ? '1970-1979' 
	  : y > 1959 
	  ? '1960-1969' 
 	  : y > 1949 
	  ? '1950-1959' 
	  : '1900-1949'
}
For the perfectionists ;)
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: Sort movies by year range (e.g. 1900-1999)

Post by kim »

why not use Switch Statement ?
https://www.tutorialspoint.com/groovy/g ... tement.htm

https://groovy-lang.org/semantics.html

e.g.

Code: Select all

{ 
	switch (y) {
		case {y > 2019}:
			return '2020'
		case {y > 2014}:
			return '2015-2019'
		case {y > 2009}:
			return '2010-2014'
		default:
			return 'bad year'
	}
}
Post Reply