Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: tonysathre
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

@echo off
setLocal EnableDelayedExpansionoushd G:\Media\Movies
for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0for /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

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

Hi Tony,
I had a typo. Try this:
@echo off
setLocal EnableDelayedExpansionpushd G:\Media\Movies
for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0for /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

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.exepushd G:\Media\Movies
for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0for /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
)

If your directories have LFNS you need them in quites.
=====================================
If at first you don't succeed, you're about average.M2

change this:
for /f "tokens=* delims= " %%f in ('dir/b/ad') do (
pushd %%f
set /a N=0to:
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

![]() |
![]() |
![]() |

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