batch-analyze movies for specific properties
batch-analyze movies for specific properties
Hello Pros
I’d like to build a script to batch-analyze a folder containing all my movie files (eintirely mkv).
My goal is it to finally have a text file listing up all file names where one of the following properties are true:
- bitrate < 3000
- x-resolution < 1920 (better != full-hd)
- at least 1 audio track < 5.1 (6 channels)
- frame rate < 24p
The text file should contain then the appropriate file names with its “true” property or its “true” properties, eg:
“Matrix (1999).mkv 2999kbs 1880x1080 2channels 22fps”
OR
“8 Mile (2002).mkv 1918x860”
...is FileBot capable of doing this?
I have a huge movie collection and want to tidy up a little bit
Thank you so far.
-remo
I’d like to build a script to batch-analyze a folder containing all my movie files (eintirely mkv).
My goal is it to finally have a text file listing up all file names where one of the following properties are true:
- bitrate < 3000
- x-resolution < 1920 (better != full-hd)
- at least 1 audio track < 5.1 (6 channels)
- frame rate < 24p
The text file should contain then the appropriate file names with its “true” property or its “true” properties, eg:
“Matrix (1999).mkv 2999kbs 1880x1080 2channels 22fps”
OR
“8 Mile (2002).mkv 1918x860”
...is FileBot capable of doing this?
I have a huge movie collection and want to tidy up a little bit
Thank you so far.
-remo
Re: batch-analyze movies for specific properties
The filebot -mediainfo command can do that.
e.g. use --filter to select only files that match your criteria:
e.g. print the results for your conditions for all files:
EDIT:
You can then combine that with -exec to batch-delete these files:
viewtopic.php?t=11078
e.g. use --filter to select only files that match your criteria:
Code: Select all
$ filebot -mediainfo -r . --filter "bitrate > 3000 && width >= 1920" --format "{fn} {resolution}"
Avatar 1920x1080
Code: Select all
$ filebot -mediainfo -r . --format "{fn} {bitrate > 3000} {width >= 1920}"
Avatar true true
EDIT:
You can then combine that with -exec to batch-delete these files:
viewtopic.php?t=11078
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Thank you. I‘ll give it a try.
Re: batch-analyze movies for specific properties
Is there also any binding to determine wether the movie‘s source is bluray or hdtv or web?
Re: batch-analyze movies for specific properties
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Great. Got it so far.
One more thing:
Is there any possibility to check if the current filename matches a specific format?
Kind of:
—filter „fn != {plex.name}“
??
One more thing:
Is there any possibility to check if the current filename matches a specific format?
Kind of:
—filter „fn != {plex.name}“
??
Re: batch-analyze movies for specific properties
I suppose this could work:
Note that {plex} only works for files that are already xattr tagged. Please read Metadata and Extended Attributes for details.
Code: Select all
f.path.contains(plex.path)
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Ok, no way.
Another idea:
does f or fn have any attribute which contains the "" property (Mediainfo-App, "" Property)
-remo
Another idea:
does f or fn have any attribute which contains the "
Code: Select all
Filename
Code: Select all
Filename
-remo
Re: batch-analyze movies for specific properties
I’ll try to describe it in another way:
When opening a movie file in Mediainfo on my Mac, there is a field labeled „Filename“. This field contains a string written into the movie file‘s metadata by MKVtoolNix - usually I do this manually.
Can FileBot CLI read out that field/property?
The FileBot GUI can!
But I didn‘t find any way via CLI.
-remo
When opening a movie file in Mediainfo on my Mac, there is a field labeled „Filename“. This field contains a string written into the movie file‘s metadata by MKVtoolNix - usually I do this manually.
Can FileBot CLI read out that field/property?
The FileBot GUI can!
But I didn‘t find any way via CLI.
-remo
Re: batch-analyze movies for specific properties
You can directly access any MediaInfo property:
viewtopic.php?t=4285
{media.FileName} is the same as {fn} though, the current file name without extension.
{mediaTitle} is the media title that's embedded in the file content.
viewtopic.php?t=4285
{media.FileName} is the same as {fn} though, the current file name without extension.
{mediaTitle} is the media title that's embedded in the file content.
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Thank you very much!
This works great!
But, now I ran into another issue:
How can I catch the case when a movie file does not have set {mediaTitle}?
Let's say when it's null or empty.
My --filter statement only works when {mediaTitle} is already embedded in the file content (!= null).
Short: I want to filter files where no {mediaTitle} is set or where {mediaTitle} differs from {fn} ...
(part behind or is already working)
-remo
This works great!
But, now I ran into another issue:
How can I catch the case when a movie file does not have set {mediaTitle}?
Let's say when it's null or empty.
My --filter statement only works when {mediaTitle} is already embedded in the file content (!= null).
Short: I want to filter files where no {mediaTitle} is set or where {mediaTitle} differs from {fn} ...
(part behind or is already working)
-remo
Re: batch-analyze movies for specific properties
Read this:
viewtopic.php?t=1895
viewtopic.php?t=1895
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Got everything working so far.
But I am not able to filter for files which have null or empty mediaTitle tag.
Even after reading viewtopic.php?t=1895 multiple times and trying a lot.
Something like this would be nice:
I need some further assistance please.
-remo
But I am not able to filter for files which have null or empty mediaTitle tag.
Even after reading viewtopic.php?t=1895 multiple times and trying a lot.
Something like this would be nice:
Code: Select all
filebot -mediainfo -r . --filter "mediaTitle.size() < 1 || !mediaTitle" --format "{fn}"
-remo
Re: batch-analyze movies for specific properties
You'll want to catch mediaTitle errors and return true for those, as uncaught errors default to false as far as --filter expressions are concerned:
viewtopic.php?f=5&t=1895
Code: Select all
--filter "any{!mediaTitle}{true}"
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Thank you!
with single ' ... ' instead of double " ... " did the Job!
-remo
Code: Select all
--filter 'any{!mediaTitle}{true}'
-remo
Re: batch-analyze movies for specific properties
Here's my entire code.
I want to share my snippets for everyone who is interested in:
-remo
I want to share my snippets for everyone who is interested in:
Code: Select all
// general file info
filebot -mediainfo -r . --filter "hd != 'HD' || vf != '1080p' || ext != 'mkv' || vc != 'x264' || af != '6ch'" --format "{fn} === {hd} - {vf} - {ext} - {vc} - {af}"
// audio stream name
filebot -mediainfo -r . --filter "audio[0].title != 'Titel 1'" --format "{fn} === {audio[0].title}"
filebot -mediainfo -r . --filter "audio[1].title != 'Titel 2'" --format "{fn} === {audio[1].title}"
// audio stream language
filebot -mediainfo -r . --filter "audioLanguages[0].name != 'German'" --format "{fn} === {audioLanguages[0].name}"
filebot -mediainfo -r . --filter "audioLanguages[1].name != 'English'" --format "{fn} === {audioLanguages[1].name}"
// is first audio stream default
filebot -mediainfo -r . --filter "audio[0].default != 'Yes'" --format "{fn} === {audio[0].default}"
// first subtitle name
filebot -mediainfo -r . --filter "text[0].title != 'erzwungen'" --format "{fn} === {text[0].title}"
// first subtitle language
filebot -mediainfo -r . --filter "text[0].language != 'de'" --format "{fn} === {text[0].language}"
// is first subtitle default and forced
filebot -mediainfo -r . --filter "text[0].default != 'Yes' || text[0].forced != 'Yes'" --format "{fn} === {text[0].default} - {text[0].forced}"
// count embedded video, audio and subtitle streams
filebot -mediainfo -r . --filter "video.size() > 1 || audio.size() > 2 || text.size() > 1" --format "{fn} === {video.size()} - {audio.size()} - {text.size()}"
// find files smaller than 3gb and larger than 15gb
filebot -mediainfo -r . --filter "bytes < 3000000000 || bytes > 15000000000" --format "{fn} === {gigabytes}"
// find files where embedded media title differs from actual file name
filebot -mediainfo -r . --filter "mediaTitle != fn.substring(0,fn.size()-7)" --format "{fn} === {mediaTitle}"
filebot -mediainfo -r . --filter "mediaTitle != fn" --format "{fn} === {mediaTitle}"
// find files where embedded media title is null or empty
filebot -mediainfo -r . --filter 'any{!mediaTitle}{true}' --format "{fn} === {mediaTitle}"
Re: batch-analyze movies for specific properties
One more thing to make my analyze scripts as useful as possible:
is the also a way for filebot/mediainfo to detect embedded text-based subtitles?
-remo
is the also a way for filebot/mediainfo to detect embedded text-based subtitles?
-remo
Re: batch-analyze movies for specific properties
Please read the FAQ and How to Request Help.
Re: batch-analyze movies for specific properties
Done.
Thank you very much for your incredible support!!!
-remo
Code: Select all
// is first subtitle stream not a picture-based subtitle
filebot -mediainfo -r . --filter "text[0].format != 'VobSub'" --format "{fn} === {text[0].format}"
-remo
Re: batch-analyze movies for specific properties
Is there also a way to count the results?
Re: batch-analyze movies for specific properties
wc -l is your friend:
https://stackoverflow.com/a/3137099/1514467
Code: Select all
<any commands that prints lines> | wc -l
Please read the FAQ and How to Request Help.