Using custom format in Groovy script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Using custom format in Groovy script

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

Re: Help with groovy script

Post 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.
:idea: Please read the FAQ and How to Request Help.
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Re: Help with groovy script

Post by vballrican »

Thanks, and if i want that in [], it has to be [[certification, genre, y]]?
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with groovy script

Post 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.
:idea: Please read the FAQ and How to Request Help.
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Re: Using custom format in Groovy script

Post 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.
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Re: Using custom format in Groovy script

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

Re: Using custom format in Groovy script

Post 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
:idea: Please read the FAQ and How to Request Help.
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Re: Using custom format in Groovy script

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

Re: Using custom format in Groovy script

Post 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
:idea: Please read the FAQ and How to Request Help.
vballrican
Donor
Posts: 80
Joined: 21 Dec 2014, 01:29

Re: Using custom format in Groovy script

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

Re: Using custom format in Groovy script

Post 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply