Making a batch shell script to convert, merge and append (join) movie's to mkv
My movie collection (1800+) titles is on a linux server, consiting of four types of files:
A Shell script (bash) which does the following:
Afterwards, the remaining .avi files I want to merge with the command 'avimerge' to single .avi's. The goal is to clean the collection to unique .avi files (without subtitle) and unique .mkv files (with subs) with one file per movie. I've tested mkvmerge with two mkv's with embedded subtitles, and this is handled correctly :) The advice I'm seeking: What's the best approach? Making scripts to sort the files first? Or make a big script to do it all? Some pointers? I think the first step is to move all .avi's which have an .srt file to a subdirectory. Then I can do mkvmerge -o file.mkv file.avi file.srt for all file.avi. |
Code:
#!/bin/bash Code:
#!/bin/bash |
Wow, that's a fast reply, thanks!
I've tried it with a few samples, and the srt's worked, the sub's didn't. But, it turned out that mkvmerge doesn't support .sub's yet. So, I have to find a way to convert the sub's into .srt's first, but I'll look into that seperately. (I think that won't be much of a problem though: http://www.robelix.com/sub2srt/) A problem is that because the original files are not deleted, it's difficult to see which files can be deleted afterwards. Maybe it's possible to build in a feature that the merged .srt's and .avi's are moved into a 'done' folder? It's also possible to delete them after processing off course. But that's more dangerous... This is the script in it's current form: Code:
The seccond script doesn't work: beryllium:/fun/UITZOEKEN/test2/mkv # ll total 1428404 -rw-r--r-- 1 root root 729654273 2009-12-06 01:54 Der Untergang (2004).cd1.mkv -rw-r--r-- 1 root root 731584186 2009-12-06 01:54 Der Untergang (2004).cd2.mkv -rwxr-xr-x 1 root root 161 2009-12-06 01:55 merge_films.sh beryllium:/fun/UITZOEKEN/test2/mkv # ./merge_films.sh mkvmerge v2.9.8 ('C'est le bon') built on Aug 13 2009 19:49:27 Error: no output file name was given. edit: changed -0 into -o, that works now. However, now because of the spaces something goes awry: beryllium:/mnt/raid/5primary/fun/UITZOEKEN/test2/mkv # ./merge_films.sh mkvmerge v2.9.8 ('C'est le bon') built on Aug 13 2009 19:49:27 Error: The source file './Der' could not be opened successfully, or retrieving its size by seeking to the end did not work. |
It's word splitting.. quoting the last arg should fix it
|
I thought is was something like that, but isn't the argument already in "?
Code:
mkvmerge -0 "$NAME.mkv" "$FIRST" "${REST[@]/#/+}" Code:
rm $FIRST Thanks so far, already 210 files have been transformed into mkv :) |
Quote:
Actually, I suggest you print out all the old files that have been processed - if there's some error and one of the mkv's weren't properly generated, you don't want to lose those old files. Once you've verified them all, you can run Code:
while read FILE ; do |
That's a good idea, but I've tested the mkvmerge extensively which works very good (and only will execute after numerous checks) so I'll still delete them (plus it would require extreme disk space, almost 1/2 TB.).
But I'm afraid I still don't get what's wrong with Code:
mkvmerge -0 "$NAME.mkv" "$FIRST" "${REST[@]/#/+}" edit: no... apparently. |
ah, I made REST *all* of the non-first discs, not just the one for "$NAME".. oops
|
So it should be:
Code:
#!/bin/bash If it works with a few tests I'll use it in the form Code:
#!/bin/bash I also made an version for avimerge (my movies without subs are usualy avi's): Code:
#!/bin/bash |
All times are GMT -5. The time now is 01:14 PM. |