批量更改多个目录下mkv文件的标题
Batch changing titles of mkv files in multiple directories
好的,我是新手...
基本上,我使用一个名为 mkvpropedit 的工具来编辑我的 .mkv 文件的标题
我的目标是创建一个批处理所有子目录并用它们的文件名替换 mkv 文件标题。
我取得了以下进步...
for %%A in (*.mkv) do "C:\mkvpropedit.exe" "%%A" --edit info --set title="%%A"
[1] 的问题:它工作正常但不影响所有子目录,我将不得不在所有子目录中一个一个地使用批处理,这将非常耗时。
for /R "C:\whatever" %%I in (*mkv) do "C:\whatever\mkvpropedit.exe" "%%I" --edit info --set title="%%I"
问题在这里,它影响所有子目录,但我的 .mkv 文件标题以整个目录路径而不是文件名结尾。
有人可以帮我吗?非常感谢。
顺便说一句,如果有人知道如何将长目录路径设置为短格式以便在整个脚本中重复使用(例如 "C:\whatever\whatever...\mkvpropeditexe into mkvpropedit",那将很有帮助。
您是使用 %%~nI
还是 %%~nxI
(如 Gerhard Barnard 所建议的那样)取决于您想要标题的方式:仅“name”或"name.ex张力".
对于how to set a long directory pathway into a short form to be use repeated throughout the script
;用完整的 path\name 设置一个变量并使用变量:
set "mkv=C:\whatever\mkvpropedit.exe"
for /R "C:\whatever" %%I in (*.mkv) do "%mkv%" "%%I" --edit info --set title="%%~nI"
借助此线程的帮助,我开发了一个更精细的批处理脚本:
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
好的,我是新手... 基本上,我使用一个名为 mkvpropedit 的工具来编辑我的 .mkv 文件的标题 我的目标是创建一个批处理所有子目录并用它们的文件名替换 mkv 文件标题。
我取得了以下进步...
for %%A in (*.mkv) do "C:\mkvpropedit.exe" "%%A" --edit info --set title="%%A"
[1] 的问题:它工作正常但不影响所有子目录,我将不得不在所有子目录中一个一个地使用批处理,这将非常耗时。
for /R "C:\whatever" %%I in (*mkv) do "C:\whatever\mkvpropedit.exe" "%%I" --edit info --set title="%%I"
问题在这里,它影响所有子目录,但我的 .mkv 文件标题以整个目录路径而不是文件名结尾。
有人可以帮我吗?非常感谢。
顺便说一句,如果有人知道如何将长目录路径设置为短格式以便在整个脚本中重复使用(例如 "C:\whatever\whatever...\mkvpropeditexe into mkvpropedit",那将很有帮助。
您是使用 %%~nI
还是 %%~nxI
(如 Gerhard Barnard 所建议的那样)取决于您想要标题的方式:仅“name”或"name.ex张力".
对于how to set a long directory pathway into a short form to be use repeated throughout the script
;用完整的 path\name 设置一个变量并使用变量:
set "mkv=C:\whatever\mkvpropedit.exe"
for /R "C:\whatever" %%I in (*.mkv) do "%mkv%" "%%I" --edit info --set title="%%~nI"
借助此线程的帮助,我开发了一个更精细的批处理脚本:
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