I have some -001.mkv files splitted in this way
the rings of power-001.mkv
the rings of power-002.mkv
..
nightmare.return-001.mkv
nightmare.return-002.mkv
..
I need to join -001.mkv files to obtain files like this
the rings of power.mkv
nightmare.return.mkv
I thought of such a code, but doesn't work
for file in "./source/*001.mkv;" \
do \
echo mkvmerge --join \
--clusters-in-meta-seek -o "./joined/$(basename "$file")" "$file"; \
done
source is the source folder where -001.mkv
files are located
joined is the target folder
CodePudding user response:
Can you try this?
for f in ./source/*-001.mkv
do
p=${f%-001.mkv}
echo mkvmerge --clusters-in-meta-seek \
-o ./joined/"${p##*/}".mkv "$p"-*.mkv
done
Given your example, the for f in ./source/*-001.mkv
should loop though nightmare.return-001.mkv
and the rings of power-001.mkv
.
Let's assume that we're in the first iteration and $f
expands to nightmare.return-001.mkv
${f%-001.mkv}
right-side-strips-001.mkv
from$f
; that would give./source/nightmare.return
. We store this prefix in the variablep
.${p##*/}
left-side-strips all characters up to the last/
from$p
; that would givenightmare.return
.
So ... -o ./joined/"${p##*/}".mkv "$p"-*.mkv
would be equivalent to ... -o ./joined/nightmare.return.mkv ./source/nightmare.return-*.mkv
PS: Once you checked that the displayed commands correspond to what you expect then you can remove the echo