Page 1 of 1

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

Posted: 11 Aug 2024, 07:43
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
	}
}