[DOCS] find -exec

How-to guides, frequently asked questions, not-so-obvious features, etc
Post Reply
User avatar
rednoah
The Source
Posts: 23922
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[DOCS] find -exec

Post by rednoah »

filebot -find is a powerful replacement for find and find -exec that works on all platforms.


e.g. find short video files:

Shell: Select all

filebot -find --filter "f.video && minutes < 15"

e.g. find short videos and then scp them to a remote server with new shell-friendly file names:

Shell: Select all

filebot -find --filter "f.video && minutes < 15" -exec scp {f} "user@host:/volume1/videos/{fn.ascii().clean().space('_')}.{ext}"
{f} ... file path
{fn} ... file name without extension
.ascii() ... transliterate to ASCII
.clean() ... remove brackets
.space('_') ... replace whitespace with underscore
{ext} ... file extension


:idea: filebot -find and filebot -mediainfo -r . --format {f} are functionally equivalent.


:idea: The --file-order option can be used to process files in a specific order (e.g. Last-Modified time in descending order) instead of input argument order.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23922
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Use ffmpeg to combine audio/video from an mkv file and subtitles from an external srt file

Post by rednoah »

e.g. find *.eng.srt files where the corresponding *.mkv video file does not have subtitles, and then run ffmpeg to combine the *.mkv file and the *.eng.srt file into a new *.mkv file with embedded subtitles:

Shell: Select all

filebot -find /path/to/input --filter "f.hasExtension('eng.srt') && mediaFile.hasExtension('mkv') && none{ textLanguages }" -exec \
  ffmpeg -i '{ mediaFile }' -sub_charenc UTF-8 -i '{ f }' \
    -map 0 -map 1 -c copy -c:s srt \
    -metadata:s:s:0 language=eng -disposition:s:0 default \
    '{ mediaFile % ".ENG-SUB" }'


e.g.

Console Output: Select all

$ ls /volume1
Avatar.eng.srt
Avatar.mkv
$ filebot -find /volume1 --filter "f.hasExtension('eng.srt') && mediaFile.hasExtension('mkv') && none{ textLanguages }" -exec ffmpeg -i '{ mediaFile }' -sub_charenc UTF-8 -i '{ f }' -map 0 -map 1 -c copy -c:s srt -metadata:s:s:0 language=eng -disposition:s:0 default '{ mediaFile % ".ENG-SUB" }'
/volume1/Avatar.eng.srt
ffmpeg version 7.0.2-3ubuntu1 Copyright (c) 2000-2024 the FFmpeg developers
...
Input #0, matroska,webm, from '/volume1/Avatar.mkv':
...
Input #1, srt, from '/volume1/Avatar.eng.srt':
...
Output #0, matroska, to '/volume1/Avatar.ENG-SUB.mkv':
...
$ ls /volume1
Avatar.ENG-SUB.mkv
Avatar.eng.srt
Avatar.mkv
:idea: Please read the FAQ and How to Request Help.
Post Reply