windowsbatch-filemkv

Batch changing titles of mkv files in multiple directories


Ok, I'm total new at this... Basically I'm using a tool call mkvpropedit to edit the title of my .mkv files My aim is to create a batch the goes through all sub directories and replace the mkv file titles with their file name.

I have made the following progress...

for %%A in (*.mkv) do "C:\mkvpropedit.exe" "%%A" --edit info --set title="%%A"

Issue with [1]: It works fine but does not affect all sub directories and I would have to use the batch in all the sub directories one by one which will be time consuming.

for /R "C:\whatever" %%I in (*mkv) do "C:\whatever\mkvpropedit.exe" "%%I" --edit info --set title="%%I"

Issue here, It affects all sub directories but my .mkv file titles end up with the entire directory pathway instead of the file name.

Could anyone help me here? Thanks a lot in advance.

BTW if anyone know how to set a long directory pathway into a short form to be use repeated throughout the script (eg. "C:\whatever\whatever...\mkvpropeditexe into mkvpropedit", that would be helpful.


Solution

  • Whether you use %%~nI or %%~nxI (as suggested by Gerhard Barnard) depends on how you want the title: "name" only or "name.extension".

    for how to set a long directory pathway into a short form to be use repeated throughout the script; set a variable with the full path\name and use the variable:

    set "mkv=C:\whatever\mkvpropedit.exe"
    for /R "C:\whatever" %%I in (*.mkv) do "%mkv%" "%%I" --edit info --set title="%%~nI"