Convert ISO files to MKV with a batch

Discussion of advanced MakeMKV functionality, expert mode, conversion profiles
Post Reply
Nicofromlyon
Posts: 4
Joined: Sat Dec 03, 2016 10:35 am

Convert ISO files to MKV with a batch

Post by Nicofromlyon » Sat Dec 03, 2016 6:52 pm

Hi all,

I have an old NAS with hundreds of original DVDs that I had converted in ISO files.

My player is not able to read the ISO files so I want to convert all my ISO files in MKV files.

I want to automatize this operation with MAKEMKVCON.

My goals:

1) I want to include all the subtitles and languages.
2) I want the same quality as the original ISO file with no loss
3) by default, i want that the movie to be in FRENCH with no subtitles

The ISO movies are located on a NAS : \\192.168.0.130\VIDEOS\ISO

I want to save the MKV generated files here : \\192.168.0.130\VIDEOS\MKV

Could you help me to create the good command line to achieve this goal?

Tks

Nicolas (FRANCE)

Jenkins
Posts: 4
Joined: Sat Dec 10, 2016 12:22 am

Re: Convert ISO files to MKV with a batch

Post by Jenkins » Sat Dec 10, 2016 1:36 am

I wrote this a while ago which should do the trick;

Note: You CANNOT have a space between iso: and the input filename or it will break the command.

In order to prevent myself from missing this mistake, I use a SET command to create a %OPTS% (options) variable

Also, If you have many ISOs in the same folder as each other, the normal makemkv command repeated multiple times can have a disastrous effect (the output mkv's overwrite themselves)

So, I added another command to create a folder based on the name of the ISO (cool eh?)

Modifying the script to use your output directory (\\192.168.0.130\VIDEOS\MKV) is not a good idea for a batch because it requires elegant ..\.. directory traversal and can have undesired effects.

Code: Select all

@ECHO OFF

:: # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
:: #
:: # CONVERT DVDISO TO MKV 
:: #
:: # This file is written as part of the Jenkins Media Tools suite (JM Tools).
:: # FOR PRIVATE USE ONLY
:: # Package Date: 09 Nov 2015
:: # (c)2008-2016 Jenkins Media. All Rights Reserved.
:: #
:: # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:: # Web:                     http://www.jenkinsmedia.com.au
:: # Contact:                     jmtools@jenkinsmedia.com.au
:: # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:: #
:: # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

:: = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

:: # Enable extensions and Delayed Expansion
:: # Keep this at the top of any bat file with intricate loops or declarations

:: Set master local expansion and command extensions.
:: USE ONCE

@SetLocal enableextensions EnableDelayedExpansion

:: -------------------------------------------------------------
:: #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
:: #                                                           #
:: #   Detect bitness                                          #
:: #                                                           #
:: #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
:: old way
:: IF %PROCESSOR_ARCHITECTURE%"=="AMD64" GOTO 64BIT
:: GOTO 32BIT

:: MS approved way
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && SET BITN=32BIT || SET BITN=64BIT
IF %BITN%==32BIT GOTO 32BIT
IF %BITN%==64BIT GOTO 64BIT

:: -------------------------------------------------------------
:: #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
:: -------------------------------------------------------------

:: -------------------------------------------------------------
:: #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
:: #                                                           #
:: #  Detect & SET directory                                   #
:: #                                                           #
:: #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #  #
:: -------------------------------------------------------------
:64BIT

SET "PFILESX86=C:\Program Files (x86)"

GOTO CONTINUE

:: -------------------------------------------------------------

:32BIT

SET "PFILESX86=C:\Program Files"

:CONTINUE

:: Set the MakeMKV path and executable variables
SET "MAKMKV=%PFILESX86%\MakeMKV"
SET "MKMKVCONV=makemkvcon64.exe"
SET "MAKEMKV=%MAKMKV%\%MKMKVCONV%"

:: Set the ISO options
SET "OPTS=mkv iso:"

:: Our main program loop.
:: Recursively (/r) search FOR something (%%f) in all subfolders for the set file type (*.iso) and DO the setting of FILE, FILED, FILEN and FILEX if found
:: Otherwise go to the end
:: This is where delayed expansion is required, and super useful

FOR /r %%f IN (*.iso) DO (
	SET "FILE=%%f"
	SET "FILED=%%~dpf"
	SET "FILEN=%%~nf"
	SET "FILEX=%%~xf"
	SET "FILENAME=%%~nxf"
	ECHO FILE EXISTS AS "!FILE!"
	ECHO FILED SET AS "!FILED!"
	ECHO FILENAME SET AS "!FILENAME!"
	ECHO.
	ECHO Found ISO in !FILED!
	ECHO.

	REM Make target directory
	MKDIR "!FILE1D!!FILE1N!\"

	REM main program
	"%MAKEMKV%" %OPTS%"!FILE1D!!FILENAME!" all "!FILE1D!!FILE1N!\"

	ECHO.
	REM We've finished converting all ISOs. Loop will now end
)
GOTO END

:END
ECHO Finished converting at %TIME% - %DATE%
ECHO.
PAUSE
EXIT /b 0
You MUST run this batch file AS ADMIN from the top level \\192.168.0.130\VIDEOS\ISO folder or any other folder containing ISO files.

Without all the variables and the FOR loop, the command should look like this;
Remember the target directory has to exist FIRST or else it will fail.

Code: Select all

"C:\Program Files\MakeMKV\makemkvcon64.exe" mkv iso:"\\192.168.0.130\VIDEOS\ISO\MyMovie.iso" all "\\192.168.0.130\VIDEOS\ISO\MyMovie\"
The loop helps immensely when you have many ISOs in a single folder tree. It will also recursively search for ISOs in sub-folders and convert them as well.

There is only one downside, and that's MakeMKV console exe cannot be told what to Name the mkv files. You will have to rename them yourself.

Also note, makemkvcon will use the settings you have chosen inside the MakeMKV GUI.

Because you are French, you might want to open the GUI and choose French subtitles and Audio if that's what you want. Otherwise, I believe the default is English subs and English audio.

Hope this helps :)

Cheers, Jenkins

Nicofromlyon
Posts: 4
Joined: Sat Dec 03, 2016 10:35 am

Re: Convert ISO files to MKV with a batch

Post by Nicofromlyon » Wed Dec 14, 2016 7:30 pm

Great, that's a very good beginning.

I have created a batch named copy.bat with all your code, in \\192.168.0.130\VIDEOS
When i launch it, the script scans everything into my C:\ drive, i dont understand why.

It finds an Office 2016 ISO ans it tries to convert it into a MKV file.

Normal : I have an error message, it tells me that it does not find any optical drive to use...

Any idea ? I'd like to scan only in my \\192.168.0.130\VIDEOS directory.

Tks

Nicofromlyon
Posts: 4
Joined: Sat Dec 03, 2016 10:35 am

Re: Convert ISO files to MKV with a batch

Post by Nicofromlyon » Wed Dec 14, 2016 8:03 pm

I have tried with this command line :

"C:\Program Files\MakeMKV\makemkvcon64.exe" mkv iso:"\\192.168.0.130\VIDEOS\ISO\MyMovie.iso" all "\\192.168.0.130\VIDEOS\ISO\MyMovie\"

It works but :

1) it creates several *.MKV file for one ISO movie, a big one (4.2GB) and several small ones.
2) the language is french but by default, the MKV movie has the french subtitles. I want no subtitles!
3) the other languages and subtitles (english etc.) have disappeared, i want them to be available.

How can I do?

Jenkins
Posts: 4
Joined: Sat Dec 10, 2016 12:22 am

Re: Convert ISO files to MKV with a batch

Post by Jenkins » Fri Dec 16, 2016 1:14 am

Nicofromlyon wrote:Great, that's a very good beginning.

I have created a batch named copy.bat with all your code, in \\192.168.0.130\VIDEOS
When i launch it, the script scans everything into my C:\ drive, i dont understand why.

It finds an Office 2016 ISO ans it tries to convert it into a MKV file.

Normal : I have an error message, it tells me that it does not find any optical drive to use...

Any idea ? I'd like to scan only in my \\192.168.0.130\VIDEOS directory.

Tks
Ok to combat this problem, you should PUSHD into the directory you're running the .bat from

Add the following line;

Code: Select all

PUSHD "%~dp0"
CD "%~dp0"
Above the FOR loop line;

Code: Select all

FOR /r %%f IN (*.iso) DO (
So

Code: Select all

PUSHD "%~dp0"
CD "%~dp0"
FOR /r %%f IN (*.iso) DO (
And at the end, don't forget to add the POPD command;

Code: Select all

:END
POPD
ECHO Finished converting at %TIME% - %DATE%
Nicofromlyon wrote:I have tried with this command line :

"C:\Program Files\MakeMKV\makemkvcon64.exe" mkv iso:"\\192.168.0.130\VIDEOS\ISO\MyMovie.iso" all "\\192.168.0.130\VIDEOS\ISO\MyMovie\"

It works but :

1) it creates several *.MKV file for one ISO movie, a big one (4.2GB) and several small ones.
2) the language is french but by default, the MKV movie has the french subtitles. I want no subtitles!
3) the other languages and subtitles (English etc.) have disappeared, I want them to be available.

How can I do?
This is, unfortunately, just how MakeMKV works.

The large file (the 4.2GB one) should be the main movie, while the smaller other files are usually special features and/or copyright notices and production company intros etc.

There is currently no way to tell MakeMKV to selectively convert titles within an ISO from the command line. You can only do that from the GUI. :(

As far as I know, the command line MakeMKV program will mirror the settings exactly to what you have chosen in the GUI...

Because of this, the only way to remove the subtitles would most likely be to unselect all subtitles in the MakeMKV GUI, there is no command line option to do this.

Lastly, you might be able to reduce the number of MKV files it will convert by adding this parameter to the makemkvcon command;

Code: Select all

--minlength=seconds
E.G

Code: Select all

"C:\Program Files\MakeMKV\makemkvcon64.exe" mkv iso:"\\192.168.0.130\VIDEOS\ISO\MyMovie.iso" --minlength=600 all "\\192.168.0.130\VIDEOS\ISO\MyMovie\"
Will convert only titles that are longer than 10mins

If you want to convert each one manually instead of using a FOR loop, to save time you can generate a raw list of ISO files like this;

Code: Select all

@ECHO OFF
DIR /s /b /a:-d "*.iso" > "iso_list.txt"
EXIT
To break that down
/s = all subfolders
/b = "bare" list
/a:-d = exclude directories (folder names with .iso in them == rare but possible)

Hope this sorts the problems :D

-Jenkins

dsrtusr88
Posts: 1
Joined: Sun Feb 05, 2023 4:30 pm

Re: Convert ISO files to MKV with a batch

Post by dsrtusr88 » Sun Feb 05, 2023 4:34 pm

Tried this script out. When I run in admin mode it just skips straight to 'finished converting at..." and any key to exit. When I run without, I can see it running through the directory and doing everything correctly, but it fails to save.

Code: Select all

FILE EXISTS AS "Z:\user\Videos\iso files to convert\movie title (1995).iso"
FILED SET AS "Z:\user\Videos\iso files to convert\"
FILENAME SET AS "movie title (1995).iso"

Found ISO in Z:\user\Videos\iso files to convert\

Access is denied.
MakeMKV v1.17.3 win(x64-release) started
The program can't find any usable optical drives.
Using direct disc access mode
Title #1 has length of 8 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #1/1 was added (1 cell(s), 0:03:33)
Title #1/2 was added (1 cell(s), 0:02:19)
Title #2 was added (6 cell(s), 2:19:07)
Operation successfully completed
Saving 3 titles into directory file://"
File "/C7_t00.mkv already exist. Do you want to overwrite it?
File "/B2_t01.mkv already exist. Do you want to overwrite it?
File "/A1_t02.mkv already exist. Do you want to overwrite it?
Error 'OS error - The filename, directory name, or volume label syntax is incorrect' occurred while creating '"/C7_t00.mkv'
Failed to save title 0 to file "/C7_t00.mkv
Error 'OS error - The filename, directory name, or volume label syntax is incorrect' occurred while creating '"/B2_t01.mkv'
Failed to save title 1 to file "/B2_t01.mkv
Error 'OS error - The filename, directory name, or volume label syntax is incorrect' occurred while creating '"/A1_t02.mkv'
Failed to save title 2 to file "/A1_t02.mkv
0 titles saved, 3 failed
Copy complete. 0 titles saved, 3 failed.

Post Reply