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.
Whether you use %%~nI
or %%~nxI
(as suggested by Gerhard Barnard) depends on how you want the title: " n ame" only or " n ame.e x tension".
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"
Using the help from this thread, here's a little more elaborate batch script I developed:
rem This Bat file will take MKV filenames and apply them to MKV info titles
@echo off
rem Modify next line to path where mkvpropedit.exe !!!!!!!!!
cd "C:\Program Files\MKVToolNix"
set /A errors1=0
rem Modify next line to path where MKV files are. This will also modify MKV's in subdirectories. !!!!!!!!!
for /R "X:\Move" %%X in (*.mkv) DO CALL :loopbody %%X
echo.
echo.
echo Total Errors = %errors1%
echo.
pause
GOTO :EOF
:loopbody
set title0=%*
set "title1=%title0:.mkv=%"
set "title2=%title1:\=" & set "title2=%"
rem The following two lines are to remove additional info I use in the filenames.
set "title3=%title2: 1080p=%"
set "title4=%title3: 720p=%"
set command1=mkvpropedit "%title0%" --edit info --set "title=%title4%"
for /f "delims=" %%a in ('%command1%') do @set response1=%%a
echo %title2%
echo %response1%
echo.
echo.
if /i "%response1:~0,5%"=="Error" (set /A errors1=%errors1% + 1)
GOTO :EOF
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.