You are not logged in.
Pages: 1
My aim: use mkvmerge to merge .srt subs with either a .avi or mp4. I can do this on mp4 files when all are in the same directory with
#!/bin/sh
for f in *.mp4; do
mkvmerge -o "${f%.mp4}.mkv" "$f" "${f##*.srt}"
done
If possible I would like to do this in one step with either mp4 or avi files. If needed, I can repeat the script to convert avi files.
Question: How can I alter the above to be recursive when movie and the corresponding subs are in separate directories?
Thanks.
CGC
Offline
You could put your for loop inside another for loop which iterates over some directories.
Offline
As for the first part of the question
#!/bin/bash
# do I need this
shopt -s extglob
# If no specific arguments were passed to script then it will check current dir for
# certain video extensions itself
(( $# )) || set -- *.@(mkv|mp4|avi|mov); [[ -e $1 ]] || { echo "No video files"; exit 1; }
while [ $# -gt 0 ]; do
echo "$1"
shift
done
and 2nd, maybe something along
f=woot
find . -name ${f}*.srt
./subs/woot.srt
or again some sort of extended glob.
https://unix.stackexchange.com/question … rsive-glob
shopt -s globstar
f=woot
ls **/*.srt
sub.srt subs/woot.srt
ls **/${f}*.srt
subs/woot.srt
Last edited by brontosaurusrex (2019-09-09 11:44:59)
Offline
Pages: 1