Computing.Net > Forums > Programming > Batch - MKVmerge script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch - MKVmerge script

Reply to Message Icon

Name: tonysathre
Date: July 22, 2008 at 20:27:02 Pacific
OS: XP Pro
CPU/Ram: AMD X2 6400+ 4GB
Product: home made
Comment:

I have a directory with roughly 950 movies in it. About 40 of them are split into 2 parts. I found this utility called mkvmerge, that can append 2 video files into one, so I would like to have a batch script run through my movies directory, and 'mkvmerge' all the split movies, and then delete the remaining 2 halves.

My movies are located in G:\Media\Movies. Each movie is located in it's own subdirectory of this directory.

The movies that are split, have 'Part 1', and 'Part 2' in the filenames, or, 'Part One' and 'Part Two'.

The syntax for mkvmerge is:

mkvmerge -o output.mkv part1.avi +part2.avi

Sorry if this is not clear enough. If you need any additional information just ask. Any help is greatly appreciated, as it would take eons to go through this many movies manually.

~Tony



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 23, 2008 at 04:30:04 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

oushd G:\Media\Movies

for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0

for /f "tokens=* delims= " %%a in ('if exist *.avi dir /b/a-d *.avi') do (
set /a N+=1
set P!N!=%%a
)

if !N! equ 2 (
echo mkvmerge -o output.mkv !P1! + !P2!
echo del !P1! & echo del !p2!
)

popd

)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: tonysathre
Date: July 24, 2008 at 20:40:21 Pacific
Reply:

Hey, thanks a lot M2. It's very close, but it does not put the output.mkv file in the respective folder.

Thanks,

Tony


0

Response Number 3
Name: Mechanix2Go
Date: July 24, 2008 at 21:45:20 Pacific
Reply:

Hi Tony,

I had a typo. Try this:

@echo off
setLocal EnableDelayedExpansion

pushd G:\Media\Movies

for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0

for /f "tokens=* delims= " %%a in ('if exist *.avi dir /b/a-d *.avi') do (
set /a N+=1
set P!N!=%%a
)

if !N! equ 2 (
echo mkvmerge -o output.mkv !P1! + !P2!
echo del !P1! & echo del !p2!
)

popd

)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: tonysathre
Date: July 25, 2008 at 03:31:25 Pacific
Reply:

Hi M2. I noticed the typo, and fixed it. That wasn't the problem however. I would like each output.mkv to go in the currently muxing movies directory. Instead, they are being put in G:\Media\Movies. For example, if Fight Club is the current movie being muxed, I would like Fight Club.mkv to go in G:\Media\Movies\Fight Club, not, G:\Media\Movies.

Here's your script, edited slightly:

@echo off
setLocal EnableDelayedExpansion
set mkvmerge=C:\Program Files\MKVtoolnix\mkvmerge.exe

pushd G:\Media\Movies

for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0

for /f "tokens=* delims= " %%a in ('if exist *.avi dir /b/a-d *.avi') do (
set /a N+=1
set P!N!=%%a
)

if !N! equ 2 (
cls
echo Now Muxing: %%f
"%mkvmerge%" -o "%%~ff.mkv" "!P1!" +"!P2!"
echo del "!P1!" & echo del "!p2!"
)

popd

)


0

Response Number 5
Name: Mechanix2Go
Date: July 25, 2008 at 03:40:22 Pacific
Reply:

If your directories have LFNS you need them in quites.


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: tonysathre
Date: July 25, 2008 at 16:09:26 Pacific
Reply:

I don't think I follow you. Everything is quoted that should be.


0

Response Number 7
Name: Mechanix2Go
Date: July 26, 2008 at 01:20:41 Pacific
Reply:

change this:

for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0

to:

for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd "%%f"
set /a N=0


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch - MKVmerge script

Batch file script www.computing.net/answers/programming/batch-file-script/17513.html

Batch login script. www.computing.net/answers/programming/batch-login-script/18848.html

Small batch file/scripting program www.computing.net/answers/programming/small-batch-filescripting-program/2353.html