在主文件夹而不是每个子文件夹中运行mkvmerge批处理

时间:2019-05-18 07:23:05

标签: batch-file

我有一个文件夹,其中包含带字幕的电视连续剧。 例如带有子目录s01,s02 ..的“ Got”文件夹 我已经写了一个批处理命令,但是我应该在每个文件夹中单独运行它。有什么方法可以在主目录中运行它并自动完成其工作吗? 命令行:

for %%A IN (*.mkv *.avi *.mp4) do (
    "C:/Program Files/MKVToolNix\mkvmerge.exe" --no-subtitles --no-attachments --no-chapters -o "%%~nxAtemp" --language 0:und --track-name 0: --default-track 0:yes --forced-track 0:yes --language 1:eng --track-name 1: --default-track 1:yes --forced-track 1:yes "%%~A" --language 0:fre --default-track 0:yes --forced-track 0:yes "%%~nA.srt" 
    if errorlevel 1 (
        echo Warnings/errors generated during remuxing, original file not deleted
      ) else (
        del /f "%%A" "%%~nA.srt"
        echo Successfully remuxed to "%%~dpna (No Subs)%%~xa", original file deleted
     )
    )
for %%A IN (*.mkvtemp) do rename "*.mkvtemp" "*.mkv"

1 个答案:

答案 0 :(得分:0)

您需要for/R遍历文件夹:

for /R %%A IN (*.mkv *.avi *.mp4) do (
     "C:/Program Files/MKVToolNix\mkvmerge.exe" --no-subtitles --no-attachments --no-chapters -o "%%~dpnxAtemp" --language 0:und --track-name 0: --default-track 0:yes --forced-track 0:yes --language 1:eng --track-name 1: --default-track 1:yes --forced-track 1:yes "%%~fA" --language 0:fre --default-track 0:yes --forced-track 0:yes "%%~dpnA.srt"
if errorlevel 1 (
       echo Warnings/errors generated during remuxing, original file not deleted
     ) else (
       del /f "%%~fA" "%%~dpnA.srt"
       echo Successfully remuxed to "%%~dpnA (No Subs)%%~xA", original file deleted
   )
)

关于您的重命名循环:

for /R %%I IN (*.mkvtemp) do rename "%%~fI" "%%~dpnI_Remuxed.mkv"

但是您可以将其合并到原始的for循环中。