[Script] Run custom Preset from the command-line

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
rednoah
The Source
Posts: 24520
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[Script] Run custom Preset from the command-line

Post by rednoah »

The FileBot Desktop application and the filebot command-line tool are separate by design - one does not effect the other - but if you want to run a Preset that you have configured in the Desktop application from the command-line, then you can use this simple glue logic script to run a filebot -rename command with all the command-line options (e.g. custom format, database, episode order, etc) filled in from the selected Preset.


Usage:

Shell: Select all

filebot -script /path/to/preset.groovy --def name="Organize Episodes for Plex" /path/to/input

Glue Logic Script:

Groovy: Select all

#!/usr/bin/env -S filebot -script

def preset = net.filebot.ui.rename.UserPresets.findResult{ g ->
	return g.list().find{ p -> p.name == name }
}

if (preset == null) {
	die "Preset does not exist: $name"
}

log.fine "Run Preset: $preset"

rename(
	file: args,
	action: preset.action,
	db: preset.database,
	format: preset.format,
	order: preset.sortOrder,
	strict: preset.matchMode ==~ /Strict/,
	lang: preset.language
)
:idea: Please read the FAQ and How to Request Help.
Post Reply