How about sharing your CLI scripts?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

How about sharing your CLI scripts?

Postby rednoah » 16 Nov 2011, 14:48

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:

All scripts and Change Logs are on GitHub:
https://github.com/filebot/scripts

:idea: Scripts listed here can easily be called via -script fn:name. FileBot will automatically fetch and cache the code from GitHub.

:idea: You can use -script dev:name to use the latest script from the devel branch.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Sort out TV Download Folder

Postby rednoah » 10 Dec 2011, 10:16

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
:idea: This script is only an example. Learn from it and rewrite it for your needs. :idea:

@see https://github.com/filebot/scripts/blob/master/sorty.groovy
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Media Index CSV

Postby rednoah » 10 Dec 2011, 10:25

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:

Code: Select all

filebot -script fn:mi /path/to/media/ "MediaIndex.csv"
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Watch folder and rename new episodes

Postby rednoah » 19 Dec 2011, 13:47

@Deprecated Whatever it is you're trying to do, these scripts here are probably not a good solution, and the amc script (hourly with --def excludeList) is always the best option for any sort of automation task.

For this tasks there there's 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.

:idea: Almost all downloaded applications support calling a cmdline tools on completed downloads, so you could for example call the amc script, and this way of doing things should always be preferred over the watcher script here. Likewise using the amc script as scheduled task is preferred over using the housekeeping script.

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

:arrow: watcher.groovy
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:

Code: Select all

filebot -script fn:watcher -extract -rename /path/to/completed/ --output /final/destination/ --db TheTVDB




: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:

Code: Select all

filebot -script fn:housekeeping -extract -rename /path/to/completed/ --output /final/destination/ --db TheMovieDB
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Fetch Artwork and Nfo for TV Shows

Postby rednoah » 06 Jan 2012, 11:46

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 confirmation dialogs via -non-strict option (on headless machines this is the default).

Usage:

Code: Select all

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


Options:
--q name to force search query manually instead of auto-detection
--conflict override to fetch artwork from scratch and 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.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Fetch Artwork and Nfo for Movies

Postby rednoah » 06 Jan 2012, 11:50

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:

Code: Select all

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


Options:
--conflict override to fetch artwork from scratch (not just missing artwork)
-non-strict to run in non-interactive mode

Notes:
  • Movies are expected to be organized into folders. The movie is determined using the name of the parent folder of each video file.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Auto-Sort Tivo Recordings

Postby rednoah » 04 Mar 2012, 04:20

@Deprecated The sortivo script is a very early and very simple version of the amc script. Use the amc script instead.

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.

Code: Select all

filebot -script fn:sortivo <folder> [-non-strict] [--output path/to/folder]
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

The Cleaner

Postby rednoah » 21 Jul 2012, 09:50

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 (that is larger than minsize).

Usage:

Code: Select all

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

Advanced Options:
--def exts=pattern override default pattern for what extensions will be cleansed
--def terms=pattern override default pattern for for what paths will be cleansed
--def ignore=pattern paths that match this pattern will never be considered as clutter or deleted
--def minsize=bytes files smaller than minsize will be deleted as clutter regardless of extension. Default is 20 MB.
--def maxsize=bytes files larger than maxsize will never be deleted. Default is 100 MB.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Filename: Find & Replace

Postby rednoah » 13 Oct 2012, 04:58

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:

Code: Select all

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


Advanced Usage:

Code: Select all

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
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Rename All Media Folder by Folder

Postby rednoah » 22 Oct 2012, 13:11

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:

Code: Select all

filebot -script fn:renall "path/to/media" -non-strict --format "{home}/Media/{plex}"


Rename movie folders:

Code: Select all

filebot -script fn:renall "path/to/movies" -non-strict --format "{home}/Movies/{ny}" --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:

Code: Select all

--action test --log info


Options:
--def target=folder rename movie folders as a single unit (i.e. treat movie folders as if they were movie files)
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Query Rename History

Postby rednoah » 13 Nov 2012, 12:41

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:

Code: Select all

filebot -script fn:history

Print rename history for the given files or folders:

Code: Select all

filebot -script fn:history "/path/to/files"

Print old and new names in rows for easy comparison:

Code: Select all

filebot -script fn:history --format '${from.name}\n${to.name}\n'

Export history to TSV file:

Code: Select all

filebot -script fn:history --format '${from}\t${to}' > history.tsv


Options:
--format specify your own line format
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Revert Renamed Files to their Original Names

Postby rednoah » 17 Nov 2012, 06:57

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.

Copy files to their original paths:

Code: Select all

filebot -script fn:revert --action copy /path/to/files


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

Notes:
  • This script assumes that files have previously been processed with --action move/copy
  • This script does not support symlinks
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

MyEpisodes.com Integration

Postby rednoah » 06 Dec 2012, 20:37

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':

Code: Select all

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'
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

View or Clear Extended Attributes

Postby rednoah » 25 Jul 2013, 08:08

Description:
If extended attributes are enabled and supported on your platform and filesystem FileBot will store original filename and episode/movie metadata into extended attributes for future reference by FileBot or other applications. This script allows you to view and clear these extended attributes.

View xattr for files:

Code: Select all

filebot -script fn:xattr /path/to/files

Clear xattr from files:

Code: Select all

filebot -script fn:xattr --action clear /path/to/files

Reverse rename previously renamed files to their original filenames based on original filename xattr:

Code: Select all

filebot -rename --db xattr --format "{original}" /path/to/files

View FileBot xattr metadata in json format:

Code: Select all

filebot -mediainfo --format "{json}" /path/to/files


Options:
--action clear Display and then delete xattr from all given files
--action import Import xattr metadata as tags into Finder (Mac OS X 10.10 or above)
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Convert Absolute numbers to SxE numbers

Postby rednoah » 19 Dec 2013, 15:15

Description:
You may find yourself in the situation where you have Anime episodes with absolute numbers and need to convert to SxE numbering for XBMC or other media centers. The trick is to first match/rename using absolute numbers and adding title/date so you can then in a second step match by title/date and rename with SxE information. This script will take care of all of that.

Convert Absolute to SxE numbers:

Code: Select all

filebot -script fn:abs2sxe /path/to/anime --log off
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Fetch subtitles for all files

Postby rednoah » 02 Apr 2014, 10:30

Description:
If you want to download subtitles for more than just a single folder then -get-subtitles -r in one batch with many many files can be a bad bad idea. This script will fetch subtitles folder per folder to make fetching large amounts of subtitles more reliable. Files may be included or excluded based on file creation date, last modified date, file size, video length, embedded subtitles, etc

:!: If you call this script repeatedly on the same folders or files then you MUST SET --def maxAgeDays to 30 days or less and call it no more than once per day.

Fetch subtitles for all files that have recently been created:

Code: Select all

filebot -script fn:suball /path/to/media -non-strict --def maxAgeDays=7


Fetch subtitles for all files:
You must not lookup subtitles for all files repeatedly in any kind of automated setup, or you will get banned. If you use the suball script in an automated setup then you MUST SET --def maxAgeDays to 30 days or less.

Code: Select all

filebot -script fn:suball /path/to/media



Files will be ignored and excluded from processing if one of the following conditions holds true:
  • file path matches your --def ignore pattern
  • time passed since file last-modified date is more than --def maxAgeDays
  • time passed since file last-modified date is less than --def minAgeDays
  • file size is less than --def minFileSize
  • video duration is less than --def minLengthMS
  • video file already contains embedded subtitles in a language matching your --def ignoreTextLanguage pattern (by default, if files contain subtitles of any language, no additional subtitles will be downloaded)

Options:
--lang zho set preferred subtitle language (default: eng)
--def maxAgeDays=7 set a max-age for files that will be processed, older files will be ignored
--def minAgeDays=1 set a min-age for files that will be processed, newer files will be ignored (so better subtitles can be downloaded later)
--def minFileSize=0 set a minimum file size, smaller files will be ignored (default: 50 MB)
--def minLengthMS=0 set a minimum video duration, shorter videos will be ignored (default: 10 min)
--def ignore=regex set an ignore pattern for paths that should be ignored
--def ignoreTextLanguage=regex set an ignore pattern for video files that already contain embedded subtitles in certain languages (default: .+)
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Verify File Integrity

Postby rednoah » 05 Nov 2014, 10:40

Description:
This script can be used to verify file integrity over time. On the first run the CRC32 checksum will be stored as xattr metadata. In subsequent runs the original checksum can then be compared to the actual checksum.


Calculate CRC32 and compare it to the previously stored checksum:

Code: Select all

filebot -script fn:verify /path/to/files


Options:
--log warning print only important output (such as when a CRC32 mismatch is found, or CRC32 metadata is initialized for the first time)

Notes:
  • The initially computed CRC32 checksum will be stored as text value in the xattr "CRC32" so the checksum will also be instantly available when using {crc32} in the format.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

User avatar
rednoah
The Source
Posts: 8889
Location: Taipei
Contact:

Find missing Episodes

Postby rednoah » 23 Feb 2016, 09:13

Description:
Finding missing episodes is easy once all your content has been renamed and xattr tagged with FileBot. This script will cross-check your files with the online episode data and tell you which episodes are missing.


Find missing episodes:

Code: Select all

filebot -script fn:miss /path/to/media


Options:
--log OFF print only missing episodes

Notes:
  • This script will not parse or guess any information from the filename. Files that do not contain xattr metadata will be ignored.
My (very excellent) support depends on Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:


Return to “Scripting and Automation”

Who is online

Users browsing this forum: No registered users and 1 guest