Ripping discs with makemkvcon & Windows

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

Ripping discs with makemkvcon & Windows

Post by Jenkins » Sat Dec 10, 2016 12:57 am

Hi mkv'ers

I've searched high and low and haven't found a solution for the following problem;

I'm trying to see if there is a way to 'detect' which optical drive is right-clicked in Windows for use with makemkvcon...

Typically in batch, Windows uses %1 or %~dpnx1 for the "first" file/folder/drive that is dragged onto a batch file, or in some cases right-clicked (when combined with a batch being launched from RC context menu)

I am aware of the

Code: Select all

makemkvcon -r --cache=1 info disc:9999
command but this is not enough.

Even when combined with a FOR loop to grab the standard output of the command, it's still not going to be able to detect which optical drive is %1 (%~dpn1)

Using the makemkv disc numbering system (0-9999) will not be able to identify the actual disc that is either dragged or right-clicked

Essentially I am using this command;

Code: Select all

makemkvcon.exe mkv disc:0 all c:\folder
What I am wondering is, if I can use a dynamic variable like %1 for the disc number that is selected in Computer :?:

Such as;

Code: Select all

makemkvcon.exe mkv disc:%variable% all c:\folder
Here's an example scenario;

I have 3 optical drives in my PC. If I wanted to right-click the second drive (disc:1) and use makemkvcon to rip the disc, there is currently no way of MakeMKV knowing that I've selected the second drive.
Because I've hard-coded disc:0 into the script, even with selecting the second drive (disc:1), it will obviously still try and convert the first disc (disc:0)

I realise it's a long shot, but I thought someone here might have come across this caveat before and not shared their magic with the world :wink:

The only other alternative I have thought of is getting the user to choose which drive they have selected with a prompt and inject their choice into the %variable%

Thanks in advance folks


Posts: 830
Joined: Mon Jan 07, 2013 12:23 am

Re: Ripping discs with makemkvcon & Windows

Post by ndjamena » Sat Dec 10, 2016 1:49 pm

Code: Select all

for /f usebackq %%g in (`powershell -command "&{$C=0;(New-Object -ComObject IMAPI2.MsftDiscMaster2)|%%{($DR=New-Object -ComObject IMAPI2.MsftDiscRecorder2).InitializeDiscRecorder($_);if($DR.VolumePathNames -eq '%D%'){$C};$C++}}"`) Do Set DNum=%%g
Replace '%D%' with '%~d1' or whatever. It gives you a variable called "DNum" with the drive number that matches the drive name in it.

Although you'd be better off doing the whole thing in Powershell.

My attempt:

That's an old version, the current version is too big to be pasted onto the forum so I'd have to split it into yet a third file in order to update the thread.


Code: Select all

@echo off
echo "%1"
for /f "usebackq tokens=*" %%g in (`powershell -command "&{$C=0;(New-Object -ComObject IMAPI2.MsftDiscMaster2)|%%{($DR=New-Object -ComObject IMAPI2.MsftDiscRecorder2).InitializeDiscRecorder($_);if($DR.VolumePathNames -eq '%~1'){$C};$C++}}"`) Do echo %%g


Code: Select all

Press any key to continue . . .

Code: Select all

Press any key to continue . . .

Post Reply