Scripts and Automation Scripting interface usage manual

See Examples Anything is possible

About

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.

Examples

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 think your script could be really useful to others as well then please share it in the forums.

Example Scripts

args.eachMediaFolder {
	getSubtitles(folder:it)
	rename(folder:it)
	compute(file:it.listFiles().findAll{ it.isVideo() })
}
Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.
['E:/tvshows'].eachMediaFolder{ rename(folder:it, db:'tvrage') }
['E:/anime'].eachMediaFolder{ rename(folder:it, db:'anidb') }
['E:/movies'].eachMediaFolder{ rename(folder:it, db:'opensubtitles') }
Run rename on different folder hierarchies using different episode/movie datasources.
args.getFiles().findAll{ it.isVideo() }
.sort{ a, b -> a.name.compareTo(b.name) }
.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, format, db, lang, strict)
Match files with episode/movie data and rename according to given naming scheme.
Parameters:
folder - process media files in this folder
file - process these media files
query - force series/movie name, auto-detect if not set
format - episode/movie naming scheme
db - episode/movie database
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)
Download subtitles for the given files. Lookup subtitles via hash or filename as fallback.
Parameters:
folder - process media files in this folder
file - process these media files
query - series/movie name
lang - subtitle language
output - force output format (e.g. srt)
encoding - force output charset

File verification

boolean check(folder|file)
Check given sfv/md5/sha1 files.
Parameters:
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.
Parameters:
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

Other

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

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