Page 1 of 1

How about sharing your CLI scripts?

Posted: 16 Nov 2011, 14:48
by rednoah
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?


Scripts and change logs are available 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 development branch directly from GithHub.

Media Index TSV

Posted: 10 Dec 2011, 10:25
by rednoah
Description:
  1. Write media info of all video files in the given folder and subfolders to an easily readable TSV file (e.g. open in Excel)
Usage:

Code: Select all

filebot -script fn:mi --output /path/to/MediaIndex.tsv /path/to/media/

Fetch Artwork and Nfo for TV Shows

Posted: 06 Jan 2012, 11:46
by rednoah
Description:
  1. Download artwork for all your TV Shows from TheTVDB. Fetch tvshow nfo, series and season artwork and save files according to Plex / Kodi 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
-non-strict to disable user-interaction and run headless

Notes:

Fetch Artwork and Nfo for Movies

Posted: 06 Jan 2012, 11:50
by rednoah
Description:
  1. Download artwork for all your Movies from TheMovieDB. Fetch Movie nfo and all kinds of artwork and save files according to Plex / Kodi 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:
-non-strict to run in non-interactive mode

Advanced Options:
--def extras=y Generate *.url files and fetch all available backdrops

Notes:

The Cleaner

Posted: 21 Jul 2012, 09:50
by rednoah
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.

Query Rename History

Posted: 13 Nov 2012, 12:41
by rednoah
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

View or Clear Extended Attributes

Posted: 25 Jul 2013, 08:08
by rednoah
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

Fetch subtitles for all files

Posted: 02 Apr 2014, 10:30
by rednoah
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 minAgeDays=1 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, no additional subtitles are fetched, if there are already embedded subtitles of any language)
Options:
--lang zho set preferred subtitle language (default: eng)
-non-strict enable Fuzzy Search (default: Exact Search)
--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: --lang value)

Verify File Integrity

Posted: 05 Nov 2014, 10:40
by rednoah
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 field "CRC32" so the checksum will also be instantly available when using {crc32} in the format.

Find missing Episodes

Posted: 23 Feb 2016, 09:13
by rednoah
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.

Find Duplicate Movie or Episode Files

Posted: 14 Sep 2016, 05:33
by rednoah
Description:
Finding duplicate movie or episode files is easy once all your content has been renamed and xattr tagged with FileBot. This script allows you to view or delete duplicates.


List Logical Duplicates:

Code: Select all

filebot -script fn:duplicates /path/to/files
:idea: There are logical duplicates when multiple files refer to the same movie or episode (e.g. 1080p and 4K versions of the same movie or episode).



List Binary Duplicates:

Code: Select all

filebot -script fn:duplicates --mode binary /input /output /backup
:idea: There are binary duplicates when multiple files are identical byte for byte (i.e. copies of the same file).

:!: NOTE: FileBot 4.9.2 (r7667) or higher is required to efficiently deduplicate links.


Options:
--action delete delete duplicate files
-mediainfo <options> perform -mediainfo command on duplicate files
-rename <options> perform -rename command on duplicate files


Notes:
  • In --mode logical, the --action delete option will keep only the one file with the highest video quality.
  • In --mode logical, this script will not parse or guess any information from the filename. Files that do not contain xattr metadata will be ignored.
  • In --mode binary, the --action delete option will keep only the first occurrence of a file according to the input argument order.
  • In --mode binary, this script may read files partially or entirely to compute checksums, which are then stored as xattr to speed up subsequent runs.

Write Embedded Tags

Posted: 18 Jul 2019, 09:11
by rednoah
Description:
Write embedded mp4 and mkv tags to the file content based on existing xattr metadata.

Write Embedded Tags:

Code: Select all

filebot -script fn:tags /path/to/files
:!: Beware! You are modifying files! Proceed with caution!

Notes:
  • This script requires the mkvpropedit (i.e. mkvtoolnix package) and mp4tags (i.e. mp4v2 package) command-line tools to write embedded mkv and mp4 tags.
  • This script will not parse or guess any information from the filename. Files that do not contain xattr metadata will be ignored.