[Script] Copy Xattr Metadata from Video Files to Companion Files

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

[Script] Copy Xattr Metadata from Video Files to Companion Files

Post by rednoah »

Find video files that have xattr metadata and then copy that xattr metadata to all the companion files (e.g. subtitle files) in the same folder that share the same file name:

Shell: Select all

filebot -find /path/to/input --filter 'f.video && f.metadata' --apply '{ source, target -> target.dir.listFiles{ it.isDerived(f) }*.metadata = target.metadata }'


:idea: --filter expression to select video files that have xattr metadata:

Groovy: Select all

f.video && f.metadata

:idea: --apply script to copy xattr metadata to derived-by-name companion files:

Groovy: Select all

{ source, target ->
	target.dir.listFiles{ it.isDerived(f) }*.metadata = target.metadata
}






:idea: Alternatively, the same can be accomplished with filebot -script and a standalone custom script:

Shell: Select all

filebot /path/to/input -script /path/to/copy-metadata.groovy

Groovy: Select all

args.files.each{ f ->
	if (f.video && f.metadata) {
		f.dir.listFiles{ it.isDerived(f) }*.metadata = f.metadata
	}
}
:idea: Please read the FAQ and How to Request Help.
Post Reply