Page 1 of 1

Using custom format in Groovy script

Posted: 08 Nov 2015, 06:48
by vballrican
Hello everyone, i'm using a script to rename my movies like this:

Code: Select all

args.eachMediaFolder { dir ->
   println dir
   rename(file:dir, format:'{n} ({y}) - [{certification, genre}]', db:'TheMovieDB')
}
Now i want to use a similar script for TV shows/Anime shows that renames the folder to example: Full Metal Panic! [TV-14, Action, 2002]

Using this, i get invalid argument on certification... Any ideas?

Code: Select all

args.eachMediaFolder { dir ->
   println dir
   rename(file:dir, format:'[{certification, genre ,y}]', db:'TVDB')
}
Thank you.

Re: Help with groovy script

Posted: 08 Nov 2015, 08:19
by rednoah
This is not valid Groovy code: certification, genre ,y

This is a valid Groovy code: [certification, genre, y]

Use the FileBot Format Editor to prototype your format. Also, you probably want at least {n} and {sxe} in the filename as well.

Re: Help with groovy script

Posted: 08 Nov 2015, 16:33
by vballrican
Thanks, and if i want that in [], it has to be [[certification, genre, y]]?

Re: Help with groovy script

Posted: 08 Nov 2015, 16:41
by rednoah
[certification, genre, y] is a List with 3 elements. [[certification, genre, y]] is a List which contains 1 List which contains 3 elements. It just so happens that the toString() string representation looks similar to the code.

If you have no idea what you're doing, I'd do it with simple String concat:

Code: Select all

{'['+certification+', '+genre+', '+y+']'}
Keep in mind that {...} specifies where Groovy code starts/ends.

Re: Using custom format in Groovy script

Posted: 09 Nov 2015, 16:03
by vballrican
Thank you. I will use that. And yes, i have no clue when it comes to scripting. The one i use for my Movies works just fine... was trying to get one for TV Shows/Anime shows to work. Thank you.

Re: Using custom format in Groovy script

Posted: 05 Feb 2016, 15:02
by vballrican
Rednoah, hope all is well.

I started using my groovy script to rename folders but I also want to rename the movie file as well. What do i need to add to this code to make it work? Thanks in advance.

Code: Select all

args.eachMediaFolder { dir ->
   println dir
   rename(file:dir, format:'{n} ({y}) - {[certification, genre]}', db:'TheMovieDB')
}

Re: Using custom format in Groovy script

Posted: 05 Feb 2016, 15:29
by rednoah
You don't really need a script... Just move files into a new structure in one go:

Code: Select all

filebot -rename -r /path/to/old --output /path/to/new --format "{n} ({y})/{n} ({y}) - {[certification, genre]}" --db TheMovieDB --action TEST

Re: Using custom format in Groovy script

Posted: 25 Feb 2016, 22:48
by vballrican
rednoah wrote:You don't really need a script... Just move files into a new structure in one go:

Code: Select all

filebot -rename -r /path/to/old --output /path/to/new --format "{n} ({y})/{n} ({y}) - {[certification, genre]}" --db TheMovieDB --action TEST
Thanks but I don't get arkwork and subtitles using this... How do i add artwork to it? --def artwork=y doesn't work...

Thanks.

Re: Using custom format in Groovy script

Posted: 26 Feb 2016, 04:52
by rednoah
--def artwork=y is a feature of the amc script, so you can either use the amc script, or use the artwork scripts directly. Simple -rename calls do not fetch artwork.

@see viewtopic.php?f=4&t=5#p204
@see viewtopic.php?f=4&t=5#p205

Re: Using custom format in Groovy script

Posted: 29 Feb 2016, 15:17
by vballrican
rednoah wrote:--def artwork=y is a feature of the amc script, so you can either use the amc script, or use the artwork scripts directly. Simple -rename calls do not fetch artwork.

@see viewtopic.php?f=4&t=5#p204
@see viewtopic.php?f=4&t=5#p205
Hi, I changed to using the amc script. I get artwork and folder renames now but no file renames... :|

Code: Select all

filebot -script fn:amc --output "H:/process" -non-strict "H:/test" --log-file amc.log --db TheMovieDB --action move --def artwork=y "seriesFormat=H:/Series/TV/{n} ({certification}, {genre}, {y})/Season {s}/{fn}" "animeFormat=H:/Anime/{n} ({certification}, {genre}, {y})/{fn}" "movieFormat=H:/Movies/{n} ({y}) - [{certification}, {Genre}]/{n} ({y})" "musicFormat=H:/Music/{n}/{fn}"

Re: Using custom format in Groovy script

Posted: 29 Feb 2016, 15:47
by rednoah
vballrican wrote:I get artwork and folder renames now but no file renames...
That's impossible. Either it works, or it doesn't. If it works, then files are moved exactly as per YOUR specification.
amc wrote:Make sure that you understand how format expressions work, and what bindings like {n} or {fn} mean.
I suspect you don't know what {fn} means. {fn} refers to the current/original filename.