Board index Scripting and Automation How about sharing your CLI scripts?

How about sharing your CLI scripts?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc

rednoah User avatar
The Source

Posts: 2081
Location: 北京

FileBot has introduced it's own integrated Groovy script engine so you can easily script things and then share that with people on any platform. So if you have come up with some nice scripts, why not share them with people here?

Script Index:

I'll add the really useful / interesting ones to the script repository:
http://filebot.net/scripts/

Revision history and change logs:
https://sourceforge.net/p/filebot/code/HEAD/tree/trunk/website/scripts/

TIP: Scripts listed here can easily be called via -script fn:name, e.g. fn:name will resolve to http://filebot.net/scripts/name.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 10 Dec 2011, 10:16
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
  1. Unrar completed downloads and delete archive volumes after extraction
  2. Fetch subtitles
  3. Sort/move/rename files into the given folder structure
  4. Notify XBMC about updates
Download Script:
http://filebot.net/scripts/sorty.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 10 Dec 2011, 10:25
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
  1. Write media info of all video files in the given folder and subfolders to an easily readable CSV file (e.g. open in Excel)
Usage:
filebot -script fn:mi /path/to/media/ "MediaIndex.csv"

Download Script:
http://filebot.net/scripts/mi.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

rednoah User avatar
The Source

Posts: 2081
Location: 北京

For this tasks there is actually two different scripts. One that actually hooks into the OS watching folders for changes (requires Java 7) and one that just organized everything in now and then in an predefined interval.

*** Note that these two scripts here are console-interactive so you must not redirect I/O ***

:arrow: watcher.groovy (Java 7+)
Description:
  1. Hook into the OS and recieve File modification events. Start organizing files once there are no changes for more than 5 seconds
  2. The script supports extracting archives, downloading subtitles and organizing video files. Each feature can be enabled or disabled by setting or not setting the -extract, -get-subtitles and -rename cmdline flags.
Usage:
filebot -script fn:watcher -extract -rename /path/to/completed/ --output /final/destination/ --format "TV Shows/{n}/Season {s}/{n} {sxe} {t}" --db TheTVDB

Download Script:
http://filebot.net/scripts/watcher.groovy


:arrow: housekeeping.groovy
Description:
  1. Watch folder by checking for new files every 5 minutes
  2. The script supports extracting archives, downloading subtitles and organizing video files. Each feature can be enabled or disabled by setting or not setting the -extract, -get-subtitles and -rename cmdline flags.
Usage:
filebot -script fn:housekeeping -extract -rename /path/to/completed/ --output /final/destination/ --format "Movies/{n} {y}/{n} ({y}){" CD$pi"}" --db TheMovieDB

Download Script:
http://filebot.net/scripts/housekeeping.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
  1. Download artwork for all your TV Shows from TheTVDB. Fetch tvshow nfo, series and season artwork and save files according to XBMC standards.
  2. Disable GUI tv series confirmation dialogs via -non-strict option (on headless machines this is the default).

Usage:
filebot -script fn:artwork.tvdb /path/to/tvshows/


Options:
--conflict override to fetch artwork from scratch (not just missing artwork)
-non-strict to disable user-interaction and run headless

Notes:
* Episodes are expected to be organized into Show/Season N/Episode XY structure. The TV Show will be auto-detected from files and the folder structure.

Download Script:
http://filebot.net/scripts/artwork.tvdb.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
  1. Download artwork for all your Movies from TheMovieDB. Fetch Movie nfo and all kinds of artwork and save files according to XBMC standards.
  2. Disable GUI tv series confirmation dialogs via -non-strict option (on headless machines this is the default).

Usage:
filebot -script fn:artwork.tmdb /path/to/movies/


Options:
--conflict override to fetch artwork from scratch (not just missing artwork)
-non-strict to disable user-interaction and run headless

Notes:
* Movies are expected to be organized into folders. The movie is determined using the name of the parent folder of each video file.

Download Script:
http://filebot.net/scripts/artwork.tmdb.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 04 Mar 2012, 04:20
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Sort out various movie and tv series files that are all in the same folder.

1. Check each file and figure out whether it is a movie file or an episode file and handle it accordingly.
2. Move / Rename according to the given movie or episode naming scheme.

Note:
Even if there is very little information (e.g. movie name without year, series name and episode title without SxE or original airdate) this script will still work, except there is multiple options (e.g. Serenity.mkv => Serenity (2003), Serenity (2005), etc) in which case you may need to specify -non-strict.

filebot -script fn:sortivo <folder> [-non-strict] [--output path/to/folder]

Download Script:
http://filebot.net/scripts/sortivo.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 26 Apr 2012, 16:34
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Here's a script that you can use with µTorrent as "Run program when torrent finishes" command to automatically sort out your downloads. Basically it's a combination of sorty, sortivo, artwork.* plus some code for µTorrent specific input.

The utorrent-postprocess / amc script has out grown these little scripts here and has become a key filebot feature by itself. It's got it's own thread here now:
http://filebot.sourceforge.net/forums/v ... 1561#p1561
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 21 Jul 2012, 09:50
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
  1. Delete clutter files like artwork, samples, etc in folders that have been left over after moving video files.
  2. Won't touch any file in folders where there is at least one video file.

Usage:
filebot -script fn:cleaner /path/to/media/


Options:
--action test only print files that would be deleted, but don't actually do anything
--def root=y Delete given folder as well if left empty
--def "exts=jpg|nfo|etc" pattern for what extensions will be cleansed
--def "terms=sample|trailer|etc" pattern for for what paths will be cleansed (only applies to files smaller than 100 MB)

Download Script:
http://filebot.net/scripts/cleaner.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 13 Oct 2012, 04:58
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
Regular-expression based mass-rename utility, FileBot style! Find & Replace is applied to the absolute path and not just the filename so you can restructure your folder hierarchy as well.

Simple Usage:
filebot -script fn:replace --def "e=.eng.srt" "r=.srt" /path/to/files


Advanced Usage:
filebot -script fn:replace --action copy --filter "[.]srt$" --def "e=[.](eng|english)" "r=.en" /path/to/files


Options:
--action test only print files that would be moved/copied
--conflict override allow override destination file if it already exists, otherwise it'll be skipped
--filter pattern process only files matching the given pattern

Download Script:
http://filebot.net/scripts/replace.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
This simple rename script will run through all folders and rename process everything folder by folder. It's pretty much like running filebot -rename <folder> for each folder. There is series/movie detection but it's very basic, so it's recommended to force a specific mode via setting --db <datasource>.

Rename episode or movie files:
filebot -script fn:renall "path/to/media" -non-strict


Rename movie folders:
filebot -script fn:renall "path/to/movies" -non-strict --db TheMovieDB --def target=folder


It's highly recommended to first do a dry-run in TEST MODE and see what would happen. Here's the options for that:
--action test --log info


Options:
--def target=folder rename movie folders as a whole instead of the files inside. This mode requires that each movie is already placed in its own folder.

Download Script:
http://filebot.net/scripts/renall.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 13 Nov 2012, 12:41
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
FileBot keeps an internal history of all rename operations in case you want to revert files to their original names or just want to find out the original name of a given file. Here's a script to help with that.

Print the entire rename history:
filebot -script fn:history

Print rename history for the given files or folders:
filebot -script fn:history "X:/path/to/files"


Options:
--format specify your own line format, e.g. --format "${from}\t${to}" if you want tab-separated paths

Download Script:
http://filebot.net/scripts/history.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
FileBot keeps an internal history of all rename operations in case you want to revert files to their original names. Run this script on the specified file or folder and revert all files to their original names.

Revert files to their original paths:
filebot -script fn:revert path/to/files


Options:
--action define revert operation, e.g. --action move (default) will move files back to their original location whereas --action rename will only change the filename back to the original filename but keep the file in it's current folder. You can run the script in test mode via --action test.

Download Script:
http://filebot.net/scripts/revert.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image

Post 06 Dec 2012, 20:37
rednoah User avatar
The Source

Posts: 2081
Location: 北京

Description:
Here's a script for automatically updating your MyEpisodes profile. On http://www.myepisodes.com you can keep track of your favorite shows, what episodes you have already aquired/watched and quickly check just how much time you've been wasting on watching TV. If your files are already reasonably well-named you can just run this script and it will add all your shows that are not on your list yet and tick each episode you have as 'acquired'.

Add shows and mark episodes as 'acquired':
filebot -script fn:update-mes "X:/path/to/episodes" --def login=user:pwd addshows=y


Options:
--def addshows=y|n auto-add new shows to your list or just ignore any show that is not on your list
--def tick=acquired|seen define whether episodes should be ticked as 'acquired' or 'watched'

Download Script:
http://filebot.net/scripts/update-mes.groovy
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image


Posts: 5
On "Rename All Media Folder by Folder":

1. The script is not renaming the media files inside folders for me.

2. Some titles get renamed to their English equivalent, some don't (even when available).

e.g. "Kasi az gorbehaye irani khabar nadareh" doesn't rename to "No One Knows About Persian Cats" (http://www.imdb.com/title/tt1426378/)

I'm using IMDB as source.

rednoah User avatar
The Source

Posts: 2081
Location: 北京

1. It's not supposed to. Just run it twice if you first wanna rename folders and then files. If you restructure your stuff you'd normally define a format for that and move everything into the new structure rather then renaming files in place.

2. Depends on the database you're using. TMDB respects the --lang option. With IMDb you'll get what you get regardless of your prefs.
FileBot is free software. Please help support FileBot by writing a review or considering a donation.
Image


Return to Scripting and Automation