Scripts and Automation Scripting interface usage manual

See Examples Anything is possible


FileBot makes scripting and automation as easy as it gets. Just script everything in Groovy instead of bothering with cumbersome cmd and bash scripts. It's the same on all platforms and much more powerful. The provided functions are the same as in the CLI and parameter usage is also exactly the same.


Running Scripts

filebot -script "path/to/script.groovy" args... Execute a given Groovy script. Parameters defined on the cmdline when starting a script will serve as default parameters while running that script.

Script Repository

Find scripts for common tasks here. You can just use these scripts straight away or as a reference for building your own more advanced scripts. If you wrote a really useful script please share it with us.

Script Index:

Example Scripts

args.eachMediaFolder {
	compute(file:it.listFiles{ it.isVideo() })
Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.
['E:/TV Shows' as File].eachMediaFolder{ rename(folder:it, db:'TheTVDB') }
['E:/Anime' as File].eachMediaFolder{ rename(folder:it, db:'AniDB') }
['E:/Movies' as File].eachMediaFolder{ rename(folder:it, db:'TheMovieDB') }
Run rename on different folder hierarchies using different episode/movie datasources.
args.getFiles{ it.isVideo() }
.sort{ a, b -> }
.each{ println getMediaInfo(file:it, format:'{fn} [{vf} {vc} {af}]') }
Print media info for all video files using the given format pattern.

Function Reference source

Rename media files

File[] rename(folder|file, query, output, format, db, lang, strict)
Match files with episode/movie data and rename according to given naming scheme.
folder - process media files in this folder
file - process these media files
action - rename action name or closure
conflict - define conflict handling
output - output folder, if format expression is not absolute
format - episode/movie naming scheme
db - episode/movie database
query - force series/movie name, auto-detect if not set
sortOrder - episode sort order
filter - episode filter expression
lang - preferred language for episode/movie titles
strict - turn on/off strict matching

Fetch subtitles for media files

File[] getSubtitles(folder|file, query, lang, output, encoding, strict)
Download subtitles for the given files. Lookup subtitles via hash or match by filename. If you only want to download missing subtitles you should use
so subtitles that have already been downloaded will not be downloaded again overridding existing subtitle files.
folder - process media files in this folder
file - process these media files
db - database filter expression (e.g. opensubtitles|subscene)
query - lookup subtitles by series/movie name
lang - subtitle language
output - force output format (e.g. srt)
encoding - force output charset
strict - enable matching subtitles via filename

File verification

boolean check(folder|file)
Check given sfv/md5/sha1 files.
folder - check the sfv/md5/sha1 files in this folder
file - check these sfv/md5/sha1

File compute(folder|file, output, encoding)
Compute sfv/md5/sha1 for the given files.
folder - compute checksums for files in this folder
file - compute checksums for these files
output - absolute or relative output file or just output format (sfv, md5 or sha1)
encoding - output charset, defaults to UTF-8


File[] extract(folder|file, output)
Extract files from single-volume or multi-volume archives (.zip, .rar, .7z, etc).
folder - extract all archives that are in this folder
file - extract this archive
output - output folder, defaults to archive path
conflict - define conflict handling

String[] fetchEpisodeList(query, format, db, lang)
Fetch episode data for the given tv show and format episode names.
query - tv series name
format - episode naming scheme
db - episode database
sortOrder - episode sort order
lang - preferred language for episode titles

String getMediaInfo(file, format)
Get mediainfo as defined by the given format.
file - get info for this file
format - media naming scheme


ScriptShellMethods also defines lots of extra useful functions and there is example code in the script repository.

Need some help getting started? Check the forums.