You are not logged in.
Hi,
I am struggling with bash scripting - I hope someone can straighten me out!
I have a folder with about 24 mp4 files with corresponding subtitles. e.g.
AAA.mp4
AAA.ass
.
.
ZZZ.mp4
ZZZ.ass
and I'm trying to mux them together using mkvmerge as a batch process.
I've searched online for help but nothing I've tried works.
My latest attempt is:
#!/bin/sh
for f in *.mp4; do
mkvmerge -o "${f%.mkv}" "$f" "${f##*.ass}"
done
which gives the error
Error: The name of the output file 'OVA01.mp4' and of one of the input files is the same.
This would cause mkvmerge to overwrite one of your input files.
This is most likely not what you want.
I can't seem to separate the filenames and extensions properly.
Any help would be much appreciated.
Thanks in advance.
Last edited by Head_on_a_Stick (2018-01-12 06:50:31)
Offline
for f in *.mp4; do
This is going to take the whole filename. To get rid of the extension, you're going to need something more like:
for f in `ls *.mp4 | cut -d. -f 1`; do
This will take a listing of all of the mp4 files, cut them at the period character, and print only the first field (the filename) and discard the extension.
I am not familiar with mkvmerge, though. But it seems like you are trying for:
mkvmerge -o $f.mkv $f.mp4 $f.ass
or similar.
--Ben
BL / MX / Raspbian... and a whole bunch of RHEL boxes. :)
Offline
@Kino ... this line
mkvmerge -o "${f%.mkv}" "$f" "${f##*.ass}"
should be
mkvmerge -o "${f%.mp4}.mkv" "$f" "${f##*.ass}"
EDIT:
Or even perhaps
mkvmerge -o "${f%.mp4}.mkv" "$f" "${f%.mp4}.ass"
(I'm not familiar with mkvmerge ... I'm only guessing the arguemtns; but '-o' switch is probably output file name.)
Last edited by iMBeCil (2018-01-11 14:53:00)
Postpone all your duties; if you die, you won't have to do them ..
Offline
Yes - that worked!
Thank you.
Offline
You're welcome (if the thanks is for me).
Postpone all your duties; if you die, you won't have to do them ..
Offline