2011-11-27 05:32:06 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" itemscope itemtype = "http://schema.org/Product" >
2011-11-05 00:47:53 +00:00
< head >
2011-11-27 05:32:06 +00:00
< meta http-equiv = "content-type" content = "text/html; charset=UTF-8" / >
2016-11-05 14:04:50 +00:00
< meta name = "keywords" content = "@{package.tags}" / >
2016-04-02 17:02:09 +00:00
2011-11-05 10:45:31 +00:00
< title > Scripts and Automation< / title >
2011-12-25 17:17:49 +00:00
< meta name = "description" content = "FileBot scripting allows to easily write scripts for any kind of automation in Groovy. There is no limits. Extract archives, download subtitles, rename episodes, fetch artwork and banners and delete left-behind clutter. All in one go." / >
2016-04-02 17:02:09 +00:00
2011-12-25 17:17:49 +00:00
< meta itemprop = "name" content = "FileBot Scripting and Automation" / >
< meta itemprop = "description" content = "FileBot scripting allows to easily write scripts for any kind of automation in Groovy. There is no limits. Extract archives, download subtitles, rename episodes, fetch artwork and banners and delete left-behind clutter. All in one go." / >
2016-11-05 14:04:50 +00:00
< meta itemprop = "image" content = "@{link.image.logo}" / >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< link rel = "stylesheet" href = "base.css" type = "text/css" / >
< link rel = "stylesheet" href = "code.css" type = "text/css" / >
< link rel = "icon" href = "favicon.png" / >
2016-04-02 17:02:09 +00:00
2011-11-27 05:32:06 +00:00
<!-- google +1 -->
< script type = "text/javascript" >
window.___gcfg = {lang: 'en-GB'};
2016-04-02 17:02:09 +00:00
2011-11-27 05:32:06 +00:00
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
< / script >
2016-04-02 17:02:09 +00:00
2011-12-08 15:05:34 +00:00
<!-- twitter -->
< script type = "text/javascript" >
2011-12-10 09:59:27 +00:00
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
2011-12-08 15:05:34 +00:00
< / script >
2011-11-05 00:47:53 +00:00
< / head >
< body >
2012-12-03 11:29:50 +00:00
<!-- Facebook Like Button -->
< div id = "fb-root" > < / div >
< script > ( f u n c t i o n ( d , s , i d ) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));< / script >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "page" >
2011-12-10 09:59:27 +00:00
< div class = "navigation" >
2011-11-22 16:12:20 +00:00
< div >
< ul >
2016-04-02 17:02:09 +00:00
< li > < a href = "http://www.filebot.net/forums/" > Forums< / a > < / li >
< li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=3&t=7" > FAQ< / a > < / li >
2015-06-01 19:26:44 +00:00
< li > < a href = "http://www.filebot.net/#download" > Download< / a > < / li >
2011-11-22 16:12:20 +00:00
< / ul >
< / div >
< / div >
2011-11-05 00:47:53 +00:00
< div class = "social" >
2011-12-10 09:59:27 +00:00
< div class = "twitter" >
2013-03-09 17:15:46 +00:00
< a href = "https://twitter.com/share" class = "twitter-share-button" data-url = "http://www.filebot.net/" data-text = "FileBot - The ultimate tv renamer and subtitle downloader" data-via = "filebot_renamer" data-lang = "en" > < / a >
2011-11-27 05:15:52 +00:00
< / div >
2016-04-02 17:02:09 +00:00
2012-12-03 11:29:50 +00:00
< div class = "facebook" >
< div class = "fb-like" data-href = "https://www.facebook.com/filebot" data-send = "false" data-layout = "button_count" data-width = "80" data-show-faces = "false" > < / div >
< / div >
2016-04-02 17:02:09 +00:00
2011-12-10 09:59:27 +00:00
< div class = "plusone" >
2014-10-27 06:37:41 +00:00
< g:plusone href = "http://www.filebot.net/" > < / g:plusone >
2011-11-05 00:47:53 +00:00
< / div >
< / div >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "header" >
2015-06-01 19:26:44 +00:00
< a href = "http://www.filebot.net" > < img class = "logo" alt = "logo" src = "images/filebot.logo.svg" width = "64" height = "64" / > < / a >
2011-11-05 00:47:53 +00:00
< h1 >
2011-11-05 10:45:31 +00:00
Scripts and Automation
2011-11-05 00:47:53 +00:00
< span class = "description" > Scripting interface usage manual< / span >
< / h1 >
< / div >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "content" >
< div class = "section screenshot" style = "border:none; box-shadow:none; background:white; margin-left: 20px" >
2014-03-18 20:16:39 +00:00
< a href = "https://github.com/filebot/scripts" target = "_blank" > < img alt = "See Examples" src = "images/script.png" / > < / a >
2011-11-05 00:47:53 +00:00
< span class = "quote" > Anything is possible< / span >
< / div >
< div class = "section about" >
< h2 > About< / h2 >
< p >
2015-06-02 11:46:03 +00:00
FileBot makes scripting and automation as easy as it gets. Just script everything in < a href = "http://groovy-lang.org/" > Groovy< / a >
2011-11-05 00:47:53 +00:00
instead of bothering with cumbersome cmd and bash scripts. It's the same on all platforms and much more powerful.
The provided < a href = "#functions" > functions< / a > are the same as in the < a href = "cli.html" > CLI< / a > and < a href = "cli.html#arguments" > parameter usage< / a >
is also exactly the same.
< / p >
2013-11-12 04:02:36 +00:00
< h2 id = "overview" > Examples< / h2 >
< h3 id = "usage" > Running Scripts< / h3 >
2011-11-05 00:47:53 +00:00
< p >
< code > < span class = "cmd" > filebot< / span > < span class = "option" > -script< / span > < span class = "argument" > "path/to/script.groovy"< / span > < span class = "argument" > args...< / span > < / code >
Execute a given Groovy script. Parameters defined on the cmdline when starting a script will serve as default parameters
2011-11-07 16:27:52 +00:00
while running that script.
2011-11-05 00:47:53 +00:00
< / p >
2013-11-12 04:02:36 +00:00
< h3 id = "repository" > Script Repository< / h3 >
< p class = "description" >
2016-04-02 17:02:09 +00:00
Find scripts for common tasks < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p5" > here< / a > . You can just use these scripts straight
2011-11-26 04:57:31 +00:00
away or as a reference for building your own more advanced scripts. If you wrote a really useful script
2016-04-02 17:02:09 +00:00
please < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5" > share it with us< / a > .
2013-11-12 04:02:36 +00:00
< / p >
2013-01-13 17:08:19 +00:00
< div style = "margin: 12px 300px 20px 25px; padding: 5px; border: thin dotted lavender; background: #FDFDFF" >
2016-04-02 17:02:09 +00:00
< span style = "text-decoration: underline" > Script Index:< / span > < br / > < ul style = "margin:3px" > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p802" class = "postlink" > µTorrent / Deluge / Transmission Integration< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p204" class = "postlink" > Fetch Artwork and Nfo for TV Shows< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p205" class = "postlink" > Fetch Artwork and Nfo for Movies< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p8871" class = "postlink" > Fetch subtitles for all files< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p1341" class = "postlink" > The Cleaner - Delete left over files and folders< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p2459" class = "postlink" > Query Rename History< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p2485" class = "postlink" > Revert Renamed Files to their Original Names< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p5394" class = "postlink" > View or Clear Extended Attributes< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p512" class = "postlink" > Auto-Sort Tivo Recordings< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p2211" class = "postlink" > Rename All Media Folder by Folder< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p7188" class = "postlink" > Convert Absolute to SxE numbers< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p2100" class = "postlink" > Filename: Find & Replace< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p53" class = "postlink" > Media Index CSV< / a > < / li > < li > < a href = "http://www.filebot.net/forums/viewtopic.php?f=4&t=5#p12396" class = "postlink" > Verify File Integrity< / a > < / li > < / ul >
2013-01-13 17:08:19 +00:00
< / div >
2016-04-02 17:02:09 +00:00
2011-11-07 16:27:52 +00:00
< h3 id = "examples" > Example Scripts< / h3 >
2011-11-05 00:47:53 +00:00
< div class = "description" >
< pre > < code > args.< span class = "method" > eachMediaFolder< / span > {
2011-11-28 13:09:10 +00:00
< span class = "method" > getMissingSubtitles< / span > (< span class = "property" > folder< / span > :it)
2011-11-05 00:47:53 +00:00
< span class = "method" > rename< / span > (< span class = "property" > folder< / span > :it)
2011-12-03 08:07:56 +00:00
< span class = "method" > compute< / span > (< span class = "property" > file< / span > :it.< span class = "method" > listFiles< / span > { it.< span class = "method" > isVideo< / span > () })
2011-11-05 00:47:53 +00:00
}< / code > < / pre > Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.< / div >
< div class = "description" >
2013-10-17 07:11:32 +00:00
< pre > < code > [< span class = "string" > 'E:/TV Shows'< / span > as File].< span class = "method" > eachMediaFolder< / span > { < span class = "method" > rename< / span > (< span class = "property" > folder< / span > :it, < span class = "property" > db< / span > :< span class = "string" > 'TheTVDB'< / span > ) }
[< span class = "string" > 'E:/Anime'< / span > as File].< span class = "method" > eachMediaFolder< / span > { < span class = "method" > rename< / span > (< span class = "property" > folder< / span > :it, < span class = "property" > db< / span > :< span class = "string" > 'AniDB'< / span > ) }
[< span class = "string" > 'E:/Movies'< / span > as File].< span class = "method" > eachMediaFolder< / span > { < span class = "method" > rename< / span > (< span class = "property" > folder< / span > :it, < span class = "property" > db< / span > :< span class = "string" > 'TheMovieDB'< / span > ) }
2011-11-05 00:47:53 +00:00
< / code > < / pre > Run rename on different folder hierarchies using different episode/movie datasources.< / div >
< div class = "description" >
2011-12-03 08:07:56 +00:00
< pre > < code > args.< span class = "method" > getFiles< / span > { it.< span class = "method" > isVideo< / span > () }
2011-11-05 00:47:53 +00:00
.< span class = "method" > sort< / span > { a, b -> a.name.< span class = "method" > compareTo< / span > (b.name) }
.< span class = "method" > each< / span > { println < span class = "method" > getMediaInfo< / span > (< span class = "property" > file< / span > :it, < span class = "property" > format< / span > :< span class = "string" > '{fn} [{vf} {vc} {af}]'< / span > ) }
< / code > < / pre > Print media info for all video files using the given format pattern.< / div >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< h2 class = "reference" id = "functions" >
Function Reference
2016-08-06 07:49:13 +00:00
< a href = "https://github.com/filebot/filebot/blob/master/source/net/filebot/cli/ScriptShellBaseClass.java" class = "source" target = "_blank" > source< / a >
2011-11-05 00:47:53 +00:00
< / h2 >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "documentation" >
< h4 > Rename media files< / h4 >
2012-02-26 12:58:16 +00:00
< pre > < span class = "return" > File[]< / span > < span class = "method" > rename< / span > (< span class = "property" > folder< / span > |< span class = "property" > file< / span > , < span class = "property" > query< / span > , < span class = "property" > output< / span > , < span class = "property" > format< / span > , < span class = "property" > db< / span > , < span class = "property" > lang< / span > , < span class = "property" > strict< / span > )< / pre >
2011-11-05 00:47:53 +00:00
< div class = "text" > Match files with episode/movie data and rename according to given naming scheme.< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > folder< / span > - process media files in this folder< / dd >
< dd > < span class = "property" > file< / span > - process these media files< / dd >
2012-07-20 07:38:50 +00:00
< dd > < span class = "property" > action< / span > - rename action name or closure< / dd >
< dd > < span class = "property" > conflict< / span > - define conflict handling< / dd >
2012-02-26 12:58:16 +00:00
< dd > < span class = "property" > output< / span > - output folder, if format expression is not absolute< / dd >
2011-11-05 00:47:53 +00:00
< dd > < span class = "property" > format< / span > - episode/movie naming scheme< / dd >
< dd > < span class = "property" > db< / span > - episode/movie database< / dd >
2012-07-20 07:38:50 +00:00
< dd > < span class = "property" > query< / span > - force series/movie name, auto-detect if not set< / dd >
< dd > < span class = "property" > sortOrder< / span > - episode sort order< / dd >
< dd > < span class = "property" > filter< / span > - episode filter expression< / dd >
2011-11-05 00:47:53 +00:00
< dd > < span class = "property" > lang< / span > - preferred language for episode/movie titles< / dd >
< dd > < span class = "property" > strict< / span > - turn on/off strict matching< / dd >
< / dl >
< / div >
< div class = "documentation" >
< h4 > Fetch subtitles for media files< / h4 >
2011-11-26 04:57:31 +00:00
< pre > < span class = "return" > File[]< / span > < span class = "method" > getSubtitles< / span > (< span class = "property" > folder< / span > |< span class = "property" > file< / span > , < span class = "property" > query< / span > , < span class = "property" > lang< / span > , < span class = "property" > output< / span > , < span class = "property" > encoding< / span > , < span class = "property" > strict< / span > )< / pre >
2011-11-28 13:09:10 +00:00
< div class = "text" >
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 < pre style = "font-size:inherit;display:inline" > < span class = "method" > getMissingSubtitles< / span > < / pre >
so subtitles that have already been downloaded will not be downloaded again overridding existing subtitle files.
< / div >
2011-11-05 00:47:53 +00:00
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > folder< / span > - process media files in this folder< / dd >
< dd > < span class = "property" > file< / span > - process these media files< / dd >
2012-07-20 07:38:50 +00:00
< dd > < span class = "property" > db< / span > - database filter expression (e.g. opensubtitles|subscene)< / dd >
2011-11-26 04:57:31 +00:00
< dd > < span class = "property" > query< / span > - lookup subtitles by series/movie name< / dd >
2011-11-05 00:47:53 +00:00
< dd > < span class = "property" > lang< / span > - subtitle language< / dd >
< dd > < span class = "property" > output< / span > - force output format (e.g. srt)< / dd >
< dd > < span class = "property" > encoding< / span > - force output charset< / dd >
2011-11-26 04:57:31 +00:00
< dd > < span class = "property" > strict< / span > - enable matching subtitles via filename< / dd >
2011-11-05 00:47:53 +00:00
< / dl >
< / div >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "documentation" >
< h4 > File verification< / h4 >
< pre > < span class = "return" > boolean< / span > < span class = "method" > check< / span > (< span class = "property" > folder< / span > |< span class = "property" > file< / span > )< / pre >
< div class = "text" > Check given sfv/md5/sha1 files.< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > folder< / span > - check the sfv/md5/sha1 files in this folder< / dd >
< dd > < span class = "property" > file< / span > - check these sfv/md5/sha1< / dd >
< / dl >
< hr / >
< pre > < span class = "return" > File< / span > < span class = "method" > compute< / span > (< span class = "property" > folder< / span > |< span class = "property" > file< / span > , < span class = "property" > output< / span > , < span class = "property" > encoding< / span > )< / pre >
< div class = "text" > Compute sfv/md5/sha1 for the given files.< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > folder< / span > - compute checksums for files in this folder< / dd >
< dd > < span class = "property" > file< / span > - compute checksums for these files< / dd >
< dd > < span class = "property" > output< / span > - absolute or relative output file or just output format (sfv, md5 or sha1)< / dd >
< dd > < span class = "property" > encoding< / span > - output charset, defaults to UTF-8< / dd >
< / dl >
< / div >
2016-04-02 17:02:09 +00:00
2011-11-05 00:47:53 +00:00
< div class = "documentation" >
< h4 > Other< / h4 >
2012-02-26 12:58:16 +00:00
< pre > < span class = "return" > File[]< / span > < span class = "method" > extract< / span > (< span class = "property" > folder< / span > |< span class = "property" > file< / span > , < span class = "property" > output< / span > )< / pre >
< div class = "text" > Extract files from single-volume or multi-volume archives (.zip, .rar, .7z, etc).< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > folder< / span > - extract all archives that are in this folder< / dd >
< dd > < span class = "property" > file< / span > - extract this archive< / dd >
< dd > < span class = "property" > output< / span > - output folder, defaults to archive path< / dd >
2012-07-20 07:38:50 +00:00
< dd > < span class = "property" > conflict< / span > - define conflict handling< / dd >
2012-02-26 12:58:16 +00:00
< / dl >
< hr / >
2011-11-05 00:47:53 +00:00
< pre > < span class = "return" > String[]< / span > < span class = "method" > fetchEpisodeList< / span > (< span class = "property" > query< / span > , < span class = "property" > format< / span > , < span class = "property" > db< / span > , < span class = "property" > lang< / span > )< / pre >
< div class = "text" > Fetch episode data for the given tv show and format episode names.< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > query< / span > - tv series name< / dd >
< dd > < span class = "property" > format< / span > - episode naming scheme< / dd >
< dd > < span class = "property" > db< / span > - episode database< / dd >
2012-07-20 07:38:50 +00:00
< dd > < span class = "property" > sortOrder< / span > - episode sort order< / dd >
2011-11-05 00:47:53 +00:00
< dd > < span class = "property" > lang< / span > - preferred language for episode titles< / dd >
< / dl >
< hr / >
< pre > < span class = "return" > String< / span > < span class = "method" > getMediaInfo< / span > (< span class = "property" > file< / span > , < span class = "property" > format< / span > )< / pre >
< div class = "text" > Get mediainfo as defined by the given format.< / div >
< dl >
< dt > Parameters:< / dt >
< dd > < span class = "property" > file< / span > - get info for this file< / dd >
< dd > < span class = "property" > format< / span > - media naming scheme< / dd >
< / dl >
< / div >
2016-04-02 17:02:09 +00:00
2012-07-20 07:38:50 +00:00
< div class = "documentation" >
< h4 > Extras< / h4 >
< div >
2016-08-06 07:49:13 +00:00
< a href = "https://github.com/filebot/filebot/blob/master/source/net/filebot/cli/ScriptShellMethods.java" > ScriptShellMethods< / a > also defines lots of extra useful functions
2014-04-10 05:55:01 +00:00
and there is example code in the < a href = "https://github.com/filebot/scripts" > script repository< / a > .
2012-07-20 07:38:50 +00:00
< / div >
< / div >
2011-11-05 00:47:53 +00:00
< / div >
2016-04-02 17:02:09 +00:00
2011-11-27 03:53:23 +00:00
< p class = "suggestion" >
2016-04-02 17:02:09 +00:00
Need some help getting started? Check the < a href = "http://www.filebot.net/forums/viewforum.php?f=4" > forums< / a > .
2011-11-16 17:24:14 +00:00
< / p >
2016-04-02 17:02:09 +00:00
2011-11-27 03:53:23 +00:00
< div class = "metrics" >
< / div >
2016-04-02 17:02:09 +00:00
2011-11-27 03:53:23 +00:00
< div class = "footer" >
2016-01-30 20:07:06 +00:00
< p > Hosted on < a href = "http://sourceforge.net/projects/filebot/" > sourceforge.net< / a > | Creative Commons License: Attribution-NonCommercial-ShareAlike © @{tstamp.year}< / p >
2011-11-05 00:47:53 +00:00
< / div >
< / div >
< / div >
< / body >
< / html >