├── ASFMKV_EU2.12f.bat ├── ASFMKV_ExtL1.02.bat ├── ASFMKV_ExtL1.03.bat ├── ASFMKV_ExtL1.04.bat ├── ASFMKV_ExtL1.05.bat ├── ASFMKV_ExtL1.06.bat ├── ASFMKV_ExtL1.07.bat ├── ASFMKV_OLD ├── ASFMKV_1811BETA.bat ├── ASFMKV_1811GAMMA.bat ├── ASFMKV_1812TEST.bat ├── ASFMKV_1902-2.bat ├── ASFMKV_1902-3.bat ├── ASFMKV_1902-4.bat ├── ASFMKV_1902-5.bat ├── ASFMKV_1902.bat ├── ASFMKV_EU1.01.bat ├── ASFMKV_EU1.02.bat ├── ASFMKV_EU1.03.bat ├── ASFMKV_EU1.04.bat ├── ASFMKV_EU1.05.bat ├── ASFMKV_EU2.00.bat ├── ASFMKV_EU2.01.bat ├── ASFMKV_EU2.02.bat ├── ASFMKV_EU2.10.bat ├── ASFMKV_EU2.11.bat ├── ASFMKV_EasyUse.bat ├── ASFMKV_ExtL1.00.bat └── ASFMKV_ExtL1.01.bat ├── LICENSE └── README.md /ASFMKV_EU2.12f.bat: -------------------------------------------------------------------------------- 1 | @rem UTF-8 without BOM file 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 277 | if not defined searchfilter goto not_replace_filter 278 | rem 正则表达式转义 279 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 280 | echo. 281 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 282 | echo [Module_ReplaceBatch] 进度0/7 283 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 284 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 285 | echo [Module_ReplaceBatch] 进度1/7 286 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 287 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 288 | echo [Module_ReplaceBatch] 进度2/7 289 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 290 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 291 | echo [Module_ReplaceBatch] 进度3/7 292 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 293 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 294 | echo [Module_ReplaceBatch] 进度4/7 295 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 296 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 297 | echo [Module_ReplaceBatch] 进度5/7 298 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 299 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 300 | echo [Module_ReplaceBatch] 进度6/7 301 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 302 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 303 | echo [Module_ReplaceBatch] 进度7/7 304 | set "filter=%replace_output%" 305 | set "replace_output=" 306 | :not_replace_filter 307 | rem 获取基本信息 308 | set "rf=%~dp0" 309 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 310 | cd /d "%rf%" 311 | rem 变更标题 312 | if not "%debug_mode%"=="0" cls 313 | title [LOAD] 正在测试mkvmerge可用性... 314 | echo [LOAD] 正在测试mkvmerge是否可用... 315 | :check_mkvmerge 316 | rem 测试MKVmerge是否可用 317 | for /f "tokens=*" %%a in ("%exein%") do ( 318 | if exist "%%~a" ( 319 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 320 | if "%%~b"=="d" ( 321 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 322 | if exist "%%~c" set "exein=%%~c" 323 | ) 324 | ) 325 | ) 326 | ) 327 | ) 328 | 329 | call "%exein%" -V>nul 2>nul 330 | 331 | if not %errorlevel%==0 ( 332 | echo [ERROR] EXEIN所设置的路径无效 333 | ) else goto no_check_again 334 | 335 | call "mkvmerge" -V>nul 2>nul 336 | 337 | if %errorlevel%==0 ( 338 | set "exein=mkvmerge" 339 | echo [CORRECT] EXEIN=mkvmerge 340 | ) else ( 341 | echo [ERROR] 无法使用MKVmerge 342 | title [ERROR] ASFMKV can't use MKVmerge 343 | exit 344 | ) 345 | :no_check_again 346 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 347 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 348 | if "%ui_language%"=="%%~a" goto uil_check_ok 349 | ) 350 | echo [ERROR] 语言"%ui_language%"不可用 351 | echo [CORRECT] 已更改为默认语言"en" 352 | set "ui_language=en" 353 | :uil_check_ok 354 | set "ver=2.12-EasyUse" 355 | if not "%debug_mode%"=="0" cls 356 | rem 获取MKVmerge的版本信息并更改标题 357 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 358 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 359 | if "%debug_mode%"=="0" ( 360 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 361 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 362 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 363 | ) 364 | rem 如果已有输入就直接执行 365 | echo. 366 | @if "%debug_mode%"=="0" echo off 367 | call :show_custom_settings 368 | @if "%debug_mode%"=="0" echo on 369 | if defined ifolder goto check_path 370 | :need_folder 371 | rem 向用户获取路径 372 | echo. 373 | set "ifolder=" 374 | set /p ifolder=文件(或目录)路径(不带引号): 375 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 376 | if not defined ifolder ( 377 | if not "%debug_mode%"=="0" cls 378 | echo [ERR] 您没有输入任何路径! 379 | goto need_folder 380 | ) 381 | 382 | call :check_path_in 383 | if defined path_inv ( 384 | set "path_inv=" 385 | goto need_folder 386 | ) 387 | rem pause 388 | goto check_path 389 | 390 | :check_path_in 391 | cmd /c if "%ifolder%"=="%ifolder%" echo. 2>NUL 392 | if "%errorlevel%"=="0" ( 393 | set "ifolder=%ifolder%" 394 | goto :EOF 395 | ) 396 | 397 | cmd /c if "%ifolder:~1%"=="%ifolder:~1%" echo. 2>NUL 398 | if "%errorlevel%"=="0" ( 399 | set "ifolder=%ifolder:~1%" 400 | goto :EOF 401 | ) 402 | 403 | cmd /c if "%ifolder:~0,-1%"=="%ifolder:~0,-1%" echo. 2>NUL 404 | if "%errorlevel%"=="0" ( 405 | set "ifolder=%ifolder:~0,-1%" 406 | goto :EOF 407 | ) 408 | 409 | cmd /c if "%ifolder:~1,-1%"=="%ifolder:~1,-1%" echo. 2>NUL 410 | if "%errorlevel%"=="0" ( 411 | set "ifolder=%ifolder:~1,-1%" 412 | goto :EOF 413 | ) 414 | 415 | if not "%debug_mode%"=="0" cls 416 | echo [ERR] 不受支持的非法路径 417 | echo [INF] 可能是您的路径中含有非法字符 418 | set "path_inv=1" 419 | goto :EOF 420 | 421 | :check_path 422 | rem 如果路径不存在,则再次向用户获取 423 | if not exist "%ifolder%" ( 424 | if not "%debug_mode%"=="0" cls 425 | call :show_setting 426 | set "ifolder=" 427 | if not defined isSetting ( 428 | echo [ERR] 输入路径无效 429 | goto need_folder 430 | ) 431 | set "isSetting=" 432 | goto uil_check_ok 433 | ) 434 | echo. 435 | :start_encode 436 | if not "%debug_mode%"=="0" cls 437 | rem 初始化变量 438 | set working=0 439 | set error=0 440 | set count=0 441 | rem 确认是目录还是文件 442 | set "dirin=" 443 | for %%a in ("%ifolder%") do ( 444 | set "attribute=%%~aa" 445 | ) 446 | if /i %attribute:~0,1%==d set "dirin=1" 447 | if not defined attribute set "dirin=1" 448 | :time_format 449 | for /f "tokens=*" %%a in ('time /T') do ( 450 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 451 | set "work_time=%%b%%c%%d" 452 | ) 453 | ) 454 | :date_format 455 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 456 | set "work_date_1=%%~a" 457 | set "work_date_2=%%~b" 458 | set "work_date_3=%%~c" 459 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 460 | if "%%~d" GTR "%%~e" ( 461 | if not "%%~e"=="" set "work_date_1=%%e" 462 | ) else if not "%%~d"=="" set "work_date_1=%%d" 463 | ) 464 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 465 | if "%%~d" GTR "%%~e" ( 466 | if not "%%~e"=="" set "work_date_2=%%e" 467 | ) else if not "%%~d"=="" set "work_date_2=%%d" 468 | ) 469 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 470 | if "%%~d" GTR "%%~e" ( 471 | if not "%%~e"=="" set "work_date_3=%%e" 472 | ) else if not "%%~d"=="" set "work_date_3=%%d" 473 | ) 474 | ) 475 | 476 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 477 | :format_del_space 478 | set "space_cache=%test_input:~-1%" 479 | if "%space_cache%"==" " ( 480 | set "test_input=%test_input:~0,-1%" 481 | ) else ( 482 | set "work_date=%test_input%" 483 | goto format_out_space_del 484 | ) 485 | goto format_del_space 486 | :format_out_space_del 487 | 488 | set "r_out_dir=%rf%[ASFMKV]redirect-output\" 489 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%\" 490 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%\" 491 | :get_file_list 492 | rem 如果是目录则执行以下流程 493 | rem 删除先前用于记录文件列表的LOG,防止重复写入 494 | if not defined dirin ( 495 | for /f "tokens=*" %%a in ("%ifolder%") do ( 496 | cd /d "%%~dpa" 497 | set "vpath=%ifolder%" 498 | set "ifolder=%%~dpa" 499 | ) 500 | ) else cd /d "%ifolder%" 501 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 502 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 503 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 504 | echo [input.get_file_list] 正在生成运行所需的文件列表... 505 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 506 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 507 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 508 | if "%subdir%"=="0" ( 509 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 510 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 511 | if exist "%%~a" ( 512 | set /a count=count+1 513 | echo "%%~a">>"%~dp0filereader.log" 514 | ) else ( 515 | if "%ifolder:~-1%"=="\" ( 516 | call :check_path_length "%ifolder%%%~a" 517 | ) else call :check_path_length "%ifolder%\%%~a" 518 | ) 519 | ) 520 | goto INPUT_DIR_SUBDIR 521 | ) else ( 522 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 523 | set /a count=count+1 524 | echo "%%~a">>"%APPDATA%\filelist.log" 525 | ) 526 | ) 527 | goto INPUT_DIR_COUNT0 528 | :check_path_length 529 | set "path_length=%~1" 530 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 531 | goto :EOF 532 | :INPUT_DIR_SUBDIR 533 | rem 如果目标目录顶层没有文件则直接跳到下一步 534 | if %count%==0 goto INPUT_DIR_COUNT0 535 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 536 | if not defined filter goto INPUT_DIR_COUNT0 537 | set "count=0" 538 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 539 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 540 | rem 重新计数符合条件的文件 541 | if defined dirin ( 542 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 543 | ) else set count=1 544 | rem 删除临时数据记录LOG 545 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 546 | :INPUT_DIR_COUNT0 547 | rem 如果count记录的文件数为0,则报错 548 | if %count%==0 if %searchfilter%==* ( 549 | echo [ERROR] 路径为空目录! 550 | goto need_folder 551 | ) else ( 552 | echo 在路径下无法匹配到文件 553 | echo 匹配规则无效! 554 | choice /M 是否使用默认匹配规则 555 | if %errorlevel%==1 set "searchfilter=*" 556 | goto need_folder 557 | ) 558 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 559 | if exist "%~dp0filereader.log" ( 560 | rename "%~dp0filereader.log" "filelist.log" 561 | ) 562 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 563 | if defined dirin ( 564 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 565 | if exist "%%~a" ( 566 | set "vpath=%%~a" 567 | call :Module_GetOutputPath 568 | call :Module_EncapsulationMKV 569 | ) 570 | ) 571 | ) else ( 572 | rem 如果是文件则仅处理一遍 573 | call :Module_GetOutputPath 574 | call :Module_EncapsulationMKV 575 | ) 576 | :check_log_dir 577 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 578 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 579 | :ld_has_file 580 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 581 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 582 | :date_ld_has_file 583 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 584 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 585 | :Process_End 586 | title [yyfll的批量混流程序] 混流完成! 587 | if not "%debug_mode%"=="0" cls 588 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 589 | if %error% GTR 0 ( 590 | goto Has_Error 591 | ) else echo [共处理%count%项且全部处理成功] 592 | echo 任务完成! 593 | goto Batch_End 594 | :Has_Error 595 | echo [共处理%count%项,其中有%error%项未能成功处理] 596 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 597 | if "%errorlevel%"=="1" ( 598 | if exist "%logdir%" ( 599 | start %logdir% 600 | ) else echo 找不到log文件夹... 601 | echo. 602 | :Batch_End 603 | rem 删除运行所需的文件列表 604 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 605 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 606 | rem 如果是不是第三方调用则挂起 607 | if "%~1"=="" pause 608 | if not "%~1"=="" exit 609 | goto uil_check_ok 610 | :Module_EncapsulationMKV 611 | rem 如果被其他模块要求不执行封装,则立刻退出 612 | if defined notwork set "notwork=" && goto :EOF 613 | set /a working=working+1 614 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 615 | if not "%debug_mode%"=="0" cls 616 | 617 | set "setfile=%rf%mkvmerge_settings.json" 618 | 619 | echo [Replace] 正在转义JSON...请稍等... 620 | call :Module_ReplaceBackSlash "%opath%" 621 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 622 | (echo [ 623 | echo "-o", 624 | if not "%nul_output%"=="0" ( 625 | echo "%r_opath%", 626 | ) else echo "NUL", 627 | echo "--ui-language", 628 | echo "%ui_language%", 629 | echo "-v", 630 | echo "--priority", 631 | echo "%priority%",)>"%setfile%" 632 | 633 | :GetSubtitle 634 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 635 | if not defined sub[0] goto Start_Encapsulation 636 | set /a subnum=subnum-1 637 | if %subnum%==0 ( 638 | call :GetSub_Num 0 639 | set "sub[0]=" 640 | ) else ( 641 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 642 | ) 643 | goto Start_Encapsulation 644 | :GetSub_Num 645 | if not defined sub[%1] goto :EOF 646 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 647 | 648 | call :Module_ReplaceBackSlash "%subname%" 649 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 650 | (echo "%%~a",)>>"%setfile%" 651 | ) 652 | set "sub[%1]=" 653 | goto :EOF 654 | :Start_Encapsulation 655 | 656 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 657 | 658 | for /f "tokens=* usebackq" %%a in ("%rf%fonts_json.log") do ( 659 | (echo %%a)>>"%setfile%" 660 | ) 661 | 662 | call :Module_ReplaceBackSlash "%vpath%" 663 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 664 | (echo "%%~b", 665 | echo "--title", 666 | echo "[ASFMKV-%ver%] %filename%" 667 | echo ] 668 | )>>"%setfile%" 669 | ) 670 | 671 | if not "%debug%"=="0" cls 672 | call :show_custom_settings 673 | echo. 674 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 675 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 676 | :run_mkvmerge 677 | set "debug_file=%logdir%DEBUG-%working%.log" 678 | if "%nul_output%"=="0" ( 679 | set "r_level=2" 680 | ) else set "r_level=1" 681 | call "%exein%" @"%setfile%" 682 | if %errorlevel% GEQ %r_level% ( 683 | set /a error=error+1 684 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 685 | call "%exein%" -r "%debug_file%" @"%setfile%" 686 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 687 | ) 688 | goto Encapsulation_OK 689 | :Encapsulation_OK 690 | if not "%nul_output%"=="0" ( 691 | if exist "%opath%" ( 692 | for %%a in ("%opath%") do set "filelen=%%~za" 693 | ) else ( 694 | set /a error=error+1 695 | goto :EOF 696 | ) 697 | ) 698 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 699 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 700 | :DelRawFile 701 | if defined notdel goto :EOF 702 | set /a filelen=filelen/1000 703 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 704 | goto :EOF 705 | :Module_ReplaceBatch 706 | if "%~1"=="" ( 707 | goto RB.error_input 708 | ) else if "%~2"=="" ( 709 | goto RB.error_input 710 | ) 711 | set "input_string=%~1" 712 | if "%input_string:~0,1%"=="" ( 713 | echo [ERROR] 您没有输入任何字符! 714 | goto RB.error_input 715 | ) 716 | set "for_delims=%~2" 717 | if "%for_delims%"=="" ( 718 | echo [ERROR] 您没有输入任何要替换的字符! 719 | goto RB.error_input 720 | ) 721 | setlocal enabledelayedexpansion 722 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 723 | if defined delims[1] ( 724 | echo [ERROR] Replace对象必须是单个字符 725 | goto RB.error_input 726 | ) 727 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 728 | if "%%~a%%~b"=="%input_string%" ( 729 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 730 | goto RB.end_clear 731 | ) 732 | ) 733 | set "replace_to=%~3" 734 | set "output_string=" 735 | set "loop=-1" 736 | :RB.re_replace 737 | set /a loop=loop+1 738 | set "RB_cache=!input_string:~%loop%,1!" 739 | if "%RB_cache%"=="" goto RB.replace_finish 740 | if "%RB_cache%"=="%for_delims%" ( 741 | set "output_string=%output_string%%replace_to%" 742 | ) else set "output_string=%output_string%%RB_cache%" 743 | goto RB.re_replace 744 | :RB.replace_finish 745 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 746 | :RB.end_clear 747 | setlocal disabledelayedexpansion 748 | set "RB_cache=" 749 | set "input_string=" 750 | set "output_string=" 751 | set "for_delims=" 752 | set "loop=" 753 | goto :EOF 754 | :RB.error_input 755 | echo [ERROR] 输入无效 756 | pause 757 | goto RB.end_clear 758 | :Module_ReplaceBackSlash 759 | if "%~1"=="" ( 760 | goto RBS.error_input 761 | ) 762 | set "input_string=A%~1A" 763 | set "for_delims=\" 764 | setlocal enabledelayedexpansion 765 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 766 | if "%%~b"=="" ( 767 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 768 | set "input_string=" 769 | set "for_delims=" 770 | goto :EOF 771 | ) 772 | ) 773 | set "replace_to=\\" 774 | set "output_string=" 775 | 776 | for /f "tokens=1 delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 777 | set "output_string=%%a" 778 | ) 779 | set "loop=1" 780 | :RBS.re_replace 781 | set /a loop=loop+1 782 | for /f "tokens=%loop% delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 783 | set "output_string=%output_string%%replace_to%%%a" 784 | goto RBS.re_replace 785 | ) 786 | echo "%output_string:~1,-1%">"%USERPROFILE%\rforbat.log" 787 | set "input_string=" 788 | set "output_string=" 789 | set "for_delims=" 790 | set "loop=" 791 | setlocal disabledelayedexpansion 792 | goto :EOF 793 | :RBS.error_input 794 | echo [ERROR] 输入无效 795 | setlocal disabledelayedexpansion 796 | pause 797 | goto :EOF 798 | :Module_GetOutputPath 799 | goto Get_Output_Path 800 | :SubNum 801 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 802 | if "%subdir%"=="0" ( 803 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 804 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 805 | for /f "tokens=*" %%b in ("%~1") do ( 806 | rem 在filelist中寻找是否有目标字幕文件 807 | if "%%~nxa"=="%%~nxb" ( 808 | rem echo "%%~a"="%%~b" 809 | set "sub[%subnum%]=%~1" 810 | set /a subnum=subnum+1 811 | goto SubNum_loop 812 | ) 813 | ) 814 | ) 815 | ) else ( 816 | set "sub[%subnum%]=%~1" 817 | set /a subnum=subnum+1 818 | ) 819 | :SubNum_loop 820 | rem pause 821 | goto :EOF 822 | :SubNum_DVDSUB 823 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 824 | call :SubNum "%~1" 825 | goto :EOF 826 | :FontNum 827 | if "%subdir%"=="0" ( 828 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 829 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 830 | for /f "tokens=*" %%b in ("%~1") do ( 831 | rem 在filelist中寻找是否有目标字体文件 832 | if "%%~nxa"=="%%~nxb" ( 833 | set /a fontnum=fontnum+1 834 | goto FontNum_loop 835 | ) 836 | ) 837 | ) 838 | ) else ( 839 | set /a fontnum=fontnum+1 840 | goto FontNum_loop 841 | ) 842 | goto :EOF 843 | :FontNum_loop 844 | if /i "%~x1"==".ttc" ( 845 | set "ftype=application/x-truetype-font" 846 | ) else if /i "%~x1"==".otf" ( 847 | set "ftype=application/vnd.ms-opentype" 848 | ) else if /i "%~x1"==".ttf" ( 849 | set "ftype=application/x-truetype-font" 850 | ) else goto :EOF 851 | 852 | call :Module_ReplaceBackSlash "%~1" 853 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 854 | (echo "--attachment-mime-type", 855 | echo "%ftype%", 856 | echo "--attach-file", 857 | echo "%%~a",)>>"%rf%fonts_json.log" 858 | ) 859 | goto :EOF 860 | :Get_Output_Path 861 | for %%a in ("%vpath%") do set "ext=%%~xa" 862 | if /i %ext:~1%==mp4 ( 863 | echo.>nul 864 | ) else if /i %ext:~1%==mkv ( 865 | echo.>nul 866 | ) else if /i %ext:~1%==mpeg ( 867 | echo.>nul 868 | ) else if /i %ext:~1%==avi ( 869 | echo.>nul 870 | ) else if /i %ext:~1%==rmvb ( 871 | echo.>nul 872 | ) else if /i %ext:~1%==m4v ( 873 | echo.>nul 874 | ) else if /i %ext:~1%==flv ( 875 | echo.>nul 876 | ) else if /i %ext:~1%==wmv ( 877 | echo.>nul 878 | ) else if /i %ext:~1%==mpg ( 879 | echo.>nul 880 | ) else if /i %ext:~1%==rm ( 881 | echo.>nul 882 | ) else if /i %ext:~1%==qt ( 883 | echo.>nul 884 | ) else if /i %ext:~1%==ogg ( 885 | echo.>nul 886 | ) else if /i %ext:~1%==mov ( 887 | echo.>nul 888 | ) else if /i %ext:~1%==m2ts ( 889 | echo.>nul 890 | ) else if /i %ext:~1%==mts ( 891 | echo.>nul 892 | ) else if /i %ext:~1%==webm ( 893 | echo.>nul 894 | ) else ( 895 | set notwork=0 896 | set /a working=working+1 897 | goto :EOF 898 | ) 899 | set "test=" 900 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 901 | for %%a in ("%vpath%") do set "filename=%%~na" 902 | if defined outpath if not "%outpath%"=="" ( 903 | if not exist "%outpath%" mkdir "%outpath%">nul 904 | for %%a in ("%outpath%") do set "test=%%~aa" 905 | ) 906 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 907 | set "ostring=%outpath%%filename%" 908 | ) else set "ostring=%outpath%\%filename%" 909 | set "test=" 910 | set "subnum=0" 911 | set "fontnum=0" 912 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 913 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 914 | call :SubNum "%%~a" 915 | ) else call :SubNum_DVDSUB "%%~a" 916 | if not defined notfont goto notget_font 917 | 918 | if not exist "%rf%fonts_json.log" ( 919 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 920 | ) 921 | :notget_font 922 | set "file=" 923 | if defined notsub if not defined sub[0] ( 924 | if not defined font[0] ( 925 | set "notwork=0" 926 | goto :EOF 927 | ) 928 | set "notwork=" 929 | goto Start_Get_Output_Path 930 | ) else if not defined font[0] ( 931 | set "notwork=0" 932 | goto :EOF 933 | ) 934 | if not defined sub[0] ( 935 | set "notwork=0" 936 | goto :EOF 937 | ) 938 | :Start_Get_Output_Path 939 | set "ostring=%ostring%[SUB]" 940 | set filenum=1 941 | if not exist "%ostring%.mkv" ( 942 | set "opath=%ostring%.mkv" 943 | goto :EOF 944 | ) 945 | :ReGet_Output_Path 946 | set "opath=%ostring%_%filenum%.mkv" 947 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 948 | goto :EOF 949 | :Show_Help 950 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 951 | echo Copyright(c) 2018-2019 By yyfll 952 | echo. 953 | echo 显示帮助页面(本页面)可以使用以下指令: 954 | echo Call "%~dpnx0" -h 955 | echo Call "%~dpnx0" -help 956 | echo Call "%~dpnx0" /h 957 | echo Call "%~dpnx0" /? 958 | echo. 959 | echo 调用开关: 960 | echo ?h 显示帮助^(最高优先^) 961 | echo ?del [y/n] 是否删除输入文件 962 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 963 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 964 | echo ?out [path] 输出目录 965 | echo ?dir [y/n] 是否搜索子目录 966 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 967 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 968 | echo ?ffl [filter] 文件过滤器 969 | echo ?pri [0-4] 选择进程优先级 970 | echo ?uil [1-4/input] 选择Mkvmerge的语言 971 | echo ?exe [path] 自定义MKVmerge的路径 972 | echo. 973 | echo 调用注意: 974 | echo 开关必须用引号整体括起,比如 975 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 976 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 977 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 978 | echo. 979 | echo 调用方法①^(CMD^): 980 | echo ASFMKV "输入路径" "[调用开关]" 981 | echo. 982 | echo 调用方法②^(CMD^): 983 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 984 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 985 | echo. 986 | echo 调用方法③: 987 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 988 | echo. 989 | echo 进程优先级: 990 | echo [0] lowest ^(最低^) 991 | echo [1] lower^(较低^) 992 | echo [2] normal^(标准^) 993 | echo [3] higher^(较高^) 994 | echo [4] highest ^(最高/实时^) 995 | echo. 996 | echo MKVmerge输出语言: 997 | echo [1] en^(English^) 998 | echo [2] zh_CN^(简体中文^) 999 | echo [3] zh_TW^(繁體中文^) 1000 | echo [4] ja^(日本語^) 1001 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 1002 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 1003 | echo 可选的语言详见"mkvmerge --ui-language list" 1004 | echo. 1005 | echo 文件过滤器(未经测试): 1006 | echo 搜索过滤器使用标准文件搜索语法,例如: 1007 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 1008 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 1009 | echo 其实就是如何使用通配符的问题罢了 1010 | exit 1011 | :show_custom_settings 1012 | echo [CUSTOM SETTINGS] 1013 | echo [A/Active][N/Undefined] 1014 | if not defined notdel ( 1015 | echo [DEL][N] 删除输入文件 1016 | ) else @echo [DEL][A] 不删除输入文件 1017 | if not defined notsub ( 1018 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 1019 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 1020 | if not defined notfont ( 1021 | echo [FNT][N] 不封装字体(仅嵌入字幕) 1022 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 1023 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 1024 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 1025 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 1026 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 1027 | if not defined searchfilter ( 1028 | set "searchfilter=*" 1029 | set "filter=.*" 1030 | echo [FFL][N] 未使用文件过滤器 1031 | ) else ( 1032 | if not "%searchfilter%"=="*" ( 1033 | echo [FFL][A] 已加载文件过滤器"%searchfilter%" 1034 | ) else echo [FFL][N] 未使用文件过滤器 1035 | ) 1036 | echo [PRI][A] 优先级"%priority%" 1037 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 1038 | if not "%exein%"=="mkvmerge" ( 1039 | echo [EXE][A] 使用"%exein%" 1040 | ) else echo [EXE][N] 使用默认程序 1041 | goto :EOF 1042 | :show_setting 1043 | if not "%ifolder%"=="set" goto :EOF 1044 | if not "%debug_mode%"=="0" cls 1045 | cls 1046 | echo ASFMKV Settings Manager ^(ver%ver%^) 1047 | echo. 1048 | echo [可控变量] 1049 | echo [A/激活][N/未定义] 1050 | if not defined notdel ( 1051 | echo [1][N] 删除输入文件 1052 | ) else echo [1][A] 不删除输入文件 1053 | if not defined notsub ( 1054 | echo [2][N] 若没有匹配的字幕则不嵌入字体 1055 | ) else echo [2][A] 即使没有匹配到字幕也会嵌入字体 1056 | if not defined notfont ( 1057 | echo [3][N] 不封装字体(仅嵌入字幕) 1058 | ) else echo [3][A] 封装字体(同时嵌入匹配字幕与字体) 1059 | if defined outpath (echo [4][A] 输出到目录"%outpath%") else (echo [4][N] 输出到源目录) 1060 | if "%subdir%"=="0" (echo [5][A] 不搜索子目录) else (echo [5][N] 搜索子目录) 1061 | echo. 1062 | echo [特殊选项] 1063 | echo [6][B] 回到主界面 1064 | echo. 1065 | CHOICE /C 123456 /M "请选择您要调整的设定" 1066 | if "%errorlevel%"=="0" ( 1067 | cls 1068 | goto show_setting 1069 | ) else goto setting_%errorlevel% 1070 | :setting_1 1071 | if not defined notdel ( 1072 | set "notdel=1" 1073 | ) else set "notdel=" 1074 | goto show_setting 1075 | :setting_2 1076 | if not defined notsub ( 1077 | set "notsub=1" 1078 | ) else set "notsub=" 1079 | goto show_setting 1080 | :setting_3 1081 | if not defined notfont ( 1082 | set "notfont=1" 1083 | ) else set "notfont=" 1084 | goto show_setting 1085 | :setting_4 1086 | if defined outpath ( 1087 | set "outpath=" 1088 | goto show_setting 1089 | ) else ( 1090 | set /p outpath=输出路径: 1091 | ) 1092 | 1093 | if not defined outpath ( 1094 | if not "%debug_mode%"=="0" cls 1095 | echo [ERR] 您没有输入任何路径! 1096 | pause 1097 | goto show_setting 1098 | ) 1099 | 1100 | if exist "%outpath:~1,-1%" ( 1101 | set "outpath=%outpath:~1,-1%" 1102 | ) else set "outpath=%outpath%" 1103 | if not exist "%outpath%" ( 1104 | if not "%debug_mode%"=="0" cls 1105 | echo [ERR] 输入路径无效! 1106 | pause 1107 | ) 1108 | goto show_setting 1109 | :setting_5 1110 | if "%subdir%"=="0" ( 1111 | set "subdir=1" 1112 | ) else ( 1113 | set "subdir=0" 1114 | ) 1115 | goto show_setting 1116 | :setting_6 1117 | set "ifolder=" 1118 | set "isSetting=1" 1119 | goto :EOF 1120 | -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1811BETA.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1811BETA.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1811GAMMA.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1811GAMMA.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1812TEST.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1812TEST.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1902-2.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1902-2.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1902-3.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1902-3.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1902-4.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1902-4.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1902-5.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1902-5.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_1902.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_1902.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU1.01.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EU1.01.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU1.02.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EU1.02.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU1.03.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EU1.03.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU1.04.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EU1.04.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU1.05.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EU1.05.bat -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU2.00.bat: -------------------------------------------------------------------------------- 1 | @rem !This file wrote in GB2312-80(zh-Hans) code page, do not open with other code pages. But you can even open this file with UTF-8 or UTF-16, these code pages can also show the texts! 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if not defined searchfilter goto not_replace_filter 277 | rem 正则表达式转义 278 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 279 | echo. 280 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 281 | echo [Module_ReplaceBatch] 进度0/7 282 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 283 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 284 | echo [Module_ReplaceBatch] 进度1/7 285 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 286 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 287 | echo [Module_ReplaceBatch] 进度2/7 288 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 289 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 290 | echo [Module_ReplaceBatch] 进度3/7 291 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 292 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 293 | echo [Module_ReplaceBatch] 进度4/7 294 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 295 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 296 | echo [Module_ReplaceBatch] 进度5/7 297 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 298 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 299 | echo [Module_ReplaceBatch] 进度6/7 300 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 301 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 302 | echo [Module_ReplaceBatch] 进度7/7 303 | set "filter=%replace_output%" 304 | set "replace_output=" 305 | :not_replace_filter 306 | rem 获取基本信息 307 | set "rf=%~dp0" 308 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 309 | cd /d "%rf%" 310 | rem 变更标题 311 | if not "%debug_mode%"=="0" cls 312 | title [LOAD] 正在测试mkvmerge可用性... 313 | echo [LOAD] 正在测试mkvmerge是否可用... 314 | :check_mkvmerge 315 | rem 测试MKVmerge是否可用 316 | for /f "tokens=*" %%a in ("%exein%") do ( 317 | if exist "%%~a" ( 318 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 319 | if "%%~b"=="d" ( 320 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 321 | if exist "%%~c" set "exein=%%~c" 322 | ) 323 | ) 324 | ) 325 | ) 326 | ) 327 | 328 | call "%exein%" -V>nul 2>nul 329 | 330 | if not "%errorlevel%"=="0" ( 331 | echo [ERROR] EXEIN所设置的路径无效 332 | set "errorlevel=0" 333 | ) else goto no_check_again 334 | 335 | call "mkvmerge" -V>nul 2>nul 336 | 337 | if "%errorlevel%"=="0" ( 338 | set "exein=mkvmerge" 339 | echo [CORRECT] EXEIN=mkvmerge 340 | ) else ( 341 | echo [ERROR] 无法使用MKVmerge 342 | title [ERROR] ASFMKV can't use MKVmerge 343 | exit 344 | ) 345 | :no_check_again 346 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 347 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 348 | if "%ui_language%"=="%%~a" goto uil_check_ok 349 | ) 350 | echo [ERROR] 语言"%ui_language%"不可用 351 | echo [CORRECT] 已更改为默认语言"en" 352 | set "ui_language=en" 353 | :uil_check_ok 354 | set "ver=2.0-EasyUse" 355 | if not "%debug_mode%"=="0" cls 356 | rem 获取MKVmerge的版本信息并更改标题 357 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 358 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 359 | if "%debug_mode%"=="0" ( 360 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 361 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 362 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 363 | ) 364 | rem 如果已有输入就直接执行 365 | echo. 366 | @if "%debug_mode%"=="0" echo off 367 | call :show_custom_settings 368 | @if "%debug_mode%"=="0" echo on 369 | if defined ifolder goto check_path 370 | :need_folder 371 | rem 向用户获取路径 372 | echo. 373 | set "ifolder=" 374 | set /p ifolder=文件(或目录)路径(不带引号): 375 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 376 | if not defined ifolder ( 377 | if not "%debug_mode%"=="0" cls 378 | echo [ERROR] 您没有输入任何路径! 379 | goto need_folder 380 | ) 381 | if exist "%ifolder:~1,-1%" ( 382 | set "ifolder=%ifolder:~1,-1%" 383 | ) else set "ifolder=%ifolder%" 384 | rem pause 385 | :check_path 386 | rem 如果路径不存在,则再次向用户获取 387 | if not exist "%ifolder%" ( 388 | if not "%debug_mode%"=="0" cls 389 | echo [ERROR] 路径无效! 390 | goto need_folder 391 | ) 392 | echo. 393 | :start_encode 394 | if not "%debug_mode%"=="0" cls 395 | rem 初始化变量 396 | set working=0 397 | set error=0 398 | set count=0 399 | rem 确认是目录还是文件 400 | set "dirin=" 401 | for %%a in ("%ifolder%") do ( 402 | set "attribute=%%~aa" 403 | ) 404 | if /i %attribute:~0,1%==d set "dirin=1" 405 | if not defined attribute set "dirin=1" 406 | :time_format 407 | for /f "tokens=*" %%a in ('time /T') do ( 408 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 409 | set "work_time=%%b%%c%%d" 410 | ) 411 | ) 412 | :date_format 413 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 414 | set "work_date_1=%%~a" 415 | set "work_date_2=%%~b" 416 | set "work_date_3=%%~c" 417 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 418 | if "%%~d" GTR "%%~e" ( 419 | if not "%%~e"=="" set "work_date_1=%%e" 420 | ) else if not "%%~d"=="" set "work_date_1=%%d" 421 | ) 422 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 423 | if "%%~d" GTR "%%~e" ( 424 | if not "%%~e"=="" set "work_date_2=%%e" 425 | ) else if not "%%~d"=="" set "work_date_2=%%d" 426 | ) 427 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 428 | if "%%~d" GTR "%%~e" ( 429 | if not "%%~e"=="" set "work_date_3=%%e" 430 | ) else if not "%%~d"=="" set "work_date_3=%%d" 431 | ) 432 | ) 433 | 434 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 435 | :format_del_space 436 | set "space_cache=%test_input:~-1%" 437 | if "%space_cache%"==" " ( 438 | set "test_input=%test_input:~0,-1%" 439 | ) else ( 440 | set "work_date=%test_input%" 441 | goto format_out_space_del 442 | ) 443 | goto format_del_space 444 | :format_out_space_del 445 | 446 | set "r_out_dir=%rf%[ASFMKV]redirect-output" 447 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%" 448 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%" 449 | :get_file_list 450 | rem 如果是目录则执行以下流程 451 | rem 删除先前用于记录文件列表的LOG,防止重复写入 452 | if not defined dirin ( 453 | for /f "tokens=*" %%a in ("%ifolder%") do ( 454 | cd /d "%%~dpa" 455 | set "vpath=%ifolder%" 456 | set "ifolder=%%~dpa" 457 | ) 458 | ) else cd /d "%ifolder%" 459 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 460 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 461 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 462 | echo [input.get_file_list] 正在生成运行所需的文件列表... 463 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 464 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 465 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 466 | if "%subdir%"=="0" ( 467 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 468 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 469 | if exist "%%~a" ( 470 | set /a count=count+1 471 | echo "%%~a">>"%~dp0filereader.log" 472 | ) else ( 473 | if "%ifolder:~-1%"=="\" ( 474 | call :check_path_length "%ifolder%%%~a" 475 | ) else call :check_path_length "%ifolder%\%%~a" 476 | ) 477 | ) 478 | goto INPUT_DIR_SUBDIR 479 | ) else ( 480 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 481 | set /a count=count+1 482 | echo "%%~a">>"%APPDATA%\filelist.log" 483 | ) 484 | ) 485 | goto INPUT_DIR_COUNT0 486 | :check_path_length 487 | set "path_length=%~1" 488 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 489 | goto :EOF 490 | :INPUT_DIR_SUBDIR 491 | rem 如果目标目录顶层没有文件则直接跳到下一步 492 | if %count%==0 goto INPUT_DIR_COUNT0 493 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 494 | if not defined filter goto INPUT_DIR_COUNT0 495 | set "count=0" 496 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 497 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 498 | rem 重新计数符合条件的文件 499 | if defined dirin ( 500 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 501 | ) else set count=1 502 | rem 删除临时数据记录LOG 503 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 504 | :INPUT_DIR_COUNT0 505 | rem 如果count记录的文件数为0,则报错 506 | if %count%==0 if %searchfilter%==* ( 507 | echo [ERROR] 路径为空目录! 508 | goto need_folder 509 | ) else ( 510 | echo 在路径下无法匹配到文件 511 | echo 匹配规则无效! 512 | choice /M 是否使用默认匹配规则 513 | if %errorlevel%==1 set "searchfilter=*" 514 | goto need_folder 515 | ) 516 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 517 | if exist "%~dp0filereader.log" ( 518 | rename "%~dp0filereader.log" "filelist.log" 519 | ) 520 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 521 | if defined dirin ( 522 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 523 | if exist "%%~a" ( 524 | set "vpath=%%~a" 525 | call :Module_GetOutputPath 526 | call :Module_EncapsulationMKV 527 | ) 528 | ) 529 | ) else ( 530 | rem 如果是文件则仅处理一遍 531 | call :Module_GetOutputPath 532 | call :Module_EncapsulationMKV 533 | ) 534 | :check_log_dir 535 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 536 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 537 | :ld_has_file 538 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 539 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 540 | :date_ld_has_file 541 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 542 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 543 | :Process_End 544 | title [yyfll的批量混流程序] 混流完成! 545 | if not "%debug_mode%"=="0" cls 546 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 547 | if %error% GTR 0 ( 548 | goto Has_Error 549 | ) else echo [共处理%count%项且全部处理成功] 550 | echo 任务完成! 551 | goto Batch_End 552 | :Has_Error 553 | echo [共处理%count%项,其中有%error%项未能成功处理] 554 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 555 | if "%errorlevel%"=="1" ( 556 | if exist "%logdir%" ( 557 | start %logdir% 558 | ) else echo 找不到log文件夹... 559 | echo. 560 | :Batch_End 561 | rem 删除运行所需的文件列表 562 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 563 | rem 如果是不是第三方调用则挂起 564 | if "%~1"=="" pause 565 | exit 566 | :Module_EncapsulationMKV 567 | rem 如果被其他模块要求不执行封装,则立刻退出 568 | if defined notwork set "notwork=" && goto :EOF 569 | set /a working=working+1 570 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 571 | if not "%debug_mode%"=="0" cls 572 | 573 | set "setfile=%rf%mkvmerge_settings.json" 574 | 575 | echo [Replace] 正在转义JSON...请稍等... 576 | call :Module_ReplaceBatch "%opath%" "\" "\\" 577 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 578 | (echo [ 579 | echo "-o", 580 | if not "%nul_output%"=="0" ( 581 | echo "%r_opath%", 582 | ) else echo NUL, 583 | echo "--ui-language", 584 | echo "%ui_language%", 585 | echo "-v", 586 | echo "--priority", 587 | echo "%priority%", 588 | )>"%setfile%" 589 | 590 | :GetSubtitle 591 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 592 | if not defined sub[0] goto GetFont 593 | set /a subnum=subnum-1 594 | if %subnum%==0 ( 595 | call :GetSub_Num 0 596 | set "sub[0]=" 597 | ) else ( 598 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 599 | ) 600 | goto GetFont 601 | :GetSub_Num 602 | if not defined sub[%1] goto :EOF 603 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 604 | 605 | call :Module_ReplaceBatch "%subname%" "\" "\\" 606 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 607 | (echo "%%~a",)>>"%setfile%" 608 | ) 609 | set "sub[%1]=" 610 | goto :EOF 611 | :GetFont 612 | if not defined font[0] goto Start_Encapsulation 613 | set /a fontnum=fontnum-1 614 | if "%fontnum%"=="0" ( 615 | call :GetFont_Num 0 616 | set "sub[0]=" 617 | ) else ( 618 | if defined font[0] for /l %%a in (0,1,%fontnum%) do call :GetFont_Num %%a 619 | ) 620 | goto Start_Encapsulation 621 | :GetFont_Num 622 | rem 如果没有任何字体文件,则直接退出 623 | if not defined font[%1] goto :EOF 624 | rem 使用FOR读取font数组的%1项 625 | if defined font[%1] for /f "tokens=2 delims==" %%a in ('set font[%1]') do set "fontname=%%a" 626 | rem 按照字体文件的扩展名来定义附件类型 627 | for %%a in ("%fontname%") do set "fext=%%~xa" 628 | set "fext=%fext:~1%" 629 | if /i "%fext%"=="ttc" ( 630 | set "ftype=application/x-truetype-font" 631 | ) else if /i "%fext%"=="otf" ( 632 | set "ftype=application/vnd.ms-opentype" 633 | ) else if /i "%fext%"=="ttf" ( 634 | set "ftype=application/x-truetype-font" 635 | ) else set "font[%1]=" && goto GetFont_Error 636 | 637 | call :Module_ReplaceBatch "%fontname%" "\" "\\" 638 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 639 | (echo "--attachment-mime-type", 640 | echo "%ftype%", 641 | echo "--attach-file", 642 | echo "%%~b",)>>"%setfile%" 643 | ) 644 | set "font[%1]=" 645 | :GetFont_Error 646 | goto :EOF 647 | :Start_Encapsulation 648 | 649 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 650 | 651 | call :Module_ReplaceBatch "%vpath%" "\" "\\" 652 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 653 | (echo "%%~b", 654 | echo "--title", 655 | echo "[ASFMKV-%ver%] %filename%" 656 | echo ] 657 | )>>"%setfile%" 658 | ) 659 | 660 | if not "%debug%"=="0" cls 661 | call :show_custom_settings 662 | echo. 663 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 664 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 665 | :run_mkvmerge 666 | set "debug_file=%logdir%DEBUG-%working%.log" 667 | call "%exein%" @"%setfile%" 668 | if "%nul_output%"=="0" (set "r_level=2") else set "r_level=1" 669 | if %errorlevel% GEQ %r_level% ( 670 | set /a error=error+1 671 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 672 | call "%exein%" -r "%debug_file%" @"%setfile%" 673 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 674 | ) 675 | goto Encapsulation_OK 676 | :Encapsulation_OK 677 | if not "%nul_output%"=="0" ( 678 | if exist "%opath%" ( 679 | for %%a in ("%opath%") do set "filelen=%%~za" 680 | ) else ( 681 | set /a error=error+1 682 | goto :EOF 683 | ) 684 | ) 685 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 686 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 687 | :DelRawFile 688 | if defined notdel goto :EOF 689 | set /a filelen=filelen/1000 690 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 691 | goto :EOF 692 | :Module_ReplaceBatch 693 | if "%~1"=="" ( 694 | goto RB.error_input 695 | ) else if "%~2"=="" ( 696 | goto RB.error_input 697 | ) 698 | set "input_string=%~1" 699 | if "%input_string:~0,1%"=="" ( 700 | echo [ERROR] 您没有输入任何字符! 701 | goto RB.error_input 702 | ) 703 | set "for_delims=%~2" 704 | if "%for_delims%"=="" ( 705 | echo [ERROR] 您没有输入任何要替换的字符! 706 | goto RB.error_input 707 | ) 708 | setlocal enabledelayedexpansion 709 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 710 | if defined delims[1] ( 711 | echo [ERROR] Replace对象必须是单个字符 712 | goto RB.error_input 713 | ) 714 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 715 | if "%%~a%%~b"=="%input_string%" ( 716 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 717 | goto RB.end_clear 718 | ) 719 | ) 720 | set "replace_to=%~3" 721 | set "output_string=" 722 | set "loop=-1" 723 | :RB.re_replace 724 | set /a loop=loop+1 725 | set "RB_cache=!input_string:~%loop%,1!" 726 | if "%RB_cache%"=="" goto RB.replace_finish 727 | if "%RB_cache%"=="%for_delims%" ( 728 | set "output_string=%output_string%%replace_to%" 729 | ) else set "output_string=%output_string%%RB_cache%" 730 | goto RB.re_replace 731 | :RB.replace_finish 732 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 733 | :RB.end_clear 734 | setlocal disabledelayedexpansion 735 | set "RB_cache=" 736 | set "input_string=" 737 | set "output_string=" 738 | set "for_delims=" 739 | set "loop=" 740 | goto :EOF 741 | :RB.error_input 742 | echo [ERROR] 输入无效 743 | pause 744 | goto RB.end_clear 745 | :Module_GetOutputPath 746 | goto Get_Output_Path 747 | :SubNum 748 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 749 | if "%subdir%"=="0" ( 750 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 751 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 752 | for /f "tokens=*" %%b in ("%~1") do ( 753 | rem 在filelist中寻找是否有目标字幕文件 754 | if "%%~nxa"=="%%~nxb" ( 755 | rem echo "%%~a"="%%~b" 756 | set "sub[%subnum%]=%~1" 757 | set /a subnum=subnum+1 758 | goto SubNum_loop 759 | ) 760 | ) 761 | ) 762 | ) else ( 763 | set "sub[%subnum%]=%~1" 764 | set /a subnum=subnum+1 765 | ) 766 | :SubNum_loop 767 | rem pause 768 | goto :EOF 769 | :SubNum_DVDSUB 770 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 771 | call :SubNum "%~1" 772 | goto :EOF 773 | :FontNum 774 | if "%subdir%"=="0" ( 775 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 776 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 777 | for /f "tokens=*" %%b in ("%~1") do ( 778 | rem 在filelist中寻找是否有目标字体文件 779 | if "%%~nxa"=="%%~nxb" ( 780 | rem echo "%%~a"="%%~b" 781 | set "font[%fontnum%]=%~1" 782 | set /a fontnum=fontnum+1 783 | goto FontNum_loop 784 | ) 785 | ) 786 | ) 787 | ) else ( 788 | set "font[%fontnum%]=%~1" 789 | set /a fontnum=fontnum+1 790 | ) 791 | :FontNum_loop 792 | goto :EOF 793 | :Get_Output_Path 794 | for %%a in ("%vpath%") do set "ext=%%~xa" 795 | if /i %ext:~1%==mp4 ( 796 | echo.>nul 797 | ) else if /i %ext:~1%==mkv ( 798 | echo.>nul 799 | ) else if /i %ext:~1%==mpeg ( 800 | echo.>nul 801 | ) else if /i %ext:~1%==avi ( 802 | echo.>nul 803 | ) else if /i %ext:~1%==rmvb ( 804 | echo.>nul 805 | ) else if /i %ext:~1%==m4v ( 806 | echo.>nul 807 | ) else if /i %ext:~1%==flv ( 808 | echo.>nul 809 | ) else if /i %ext:~1%==wmv ( 810 | echo.>nul 811 | ) else if /i %ext:~1%==mpg ( 812 | echo.>nul 813 | ) else if /i %ext:~1%==rm ( 814 | echo.>nul 815 | ) else if /i %ext:~1%==qt ( 816 | echo.>nul 817 | ) else if /i %ext:~1%==ogg ( 818 | echo.>nul 819 | ) else if /i %ext:~1%==mov ( 820 | echo.>nul 821 | ) else if /i %ext:~1%==m2ts ( 822 | echo.>nul 823 | ) else if /i %ext:~1%==mts ( 824 | echo.>nul 825 | ) else if /i %ext:~1%==webm ( 826 | echo.>nul 827 | ) else ( 828 | set notwork=0 829 | set /a working=working+1 830 | goto :EOF 831 | ) 832 | set "test=" 833 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 834 | for %%a in ("%vpath%") do set "filename=%%~na" 835 | if defined outpath if not "%outpath%"=="" ( 836 | if not exist "%outpath%" mkdir "%outpath%">nul 837 | for %%a in ("%outpath%") do set "test=%%~aa" 838 | ) 839 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 840 | set "ostring=%outpath%%filename%" 841 | ) else set "ostring=%outpath%\%filename%" 842 | set "test=" 843 | set "subnum=0" 844 | set "fontnum=0" 845 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 846 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 847 | call :SubNum "%%~a" 848 | ) else call :SubNum_DVDSUB "%%~a" 849 | if not defined notfont goto notget_font 850 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 851 | :notget_font 852 | set "file=" 853 | if defined notsub if not defined sub[0] ( 854 | if not defined font[0] ( 855 | set "notwork=0" 856 | goto :EOF 857 | ) 858 | set "notwork=" 859 | goto Start_Get_Output_Path 860 | ) else if not defined font[0] ( 861 | set "notwork=0" 862 | goto :EOF 863 | ) 864 | if not defined sub[0] ( 865 | set "notwork=0" 866 | goto :EOF 867 | ) 868 | :Start_Get_Output_Path 869 | set "ostring=%ostring%[SUB]" 870 | set filenum=1 871 | if not exist "%ostring%.mkv" ( 872 | set "opath=%ostring%.mkv" 873 | goto :EOF 874 | ) 875 | :ReGet_Output_Path 876 | set "opath=%ostring%_%filenum%.mkv" 877 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 878 | goto :EOF 879 | :Show_Help 880 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 881 | echo Copyright(c) 2018-2019 By yyfll 882 | echo. 883 | echo 显示帮助页面(本页面)可以使用以下指令: 884 | echo Call "%~dpnx0" -h 885 | echo Call "%~dpnx0" -help 886 | echo Call "%~dpnx0" /h 887 | echo Call "%~dpnx0" /? 888 | echo. 889 | echo 调用开关: 890 | echo ?h 显示帮助^(最高优先^) 891 | echo ?del [y/n] 是否删除输入文件 892 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 893 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 894 | echo ?out [path] 输出目录 895 | echo ?dir [y/n] 是否搜索子目录 896 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 897 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 898 | echo ?ffl [filter] 文件过滤器 899 | echo ?pri [0-4] 选择进程优先级 900 | echo ?uil [1-4/input] 选择Mkvmerge的语言 901 | echo ?exe [path] 自定义MKVmerge的路径 902 | echo. 903 | echo 调用注意: 904 | echo 开关必须用引号整体括起,比如 905 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 906 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 907 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 908 | echo. 909 | echo 调用方法①^(CMD^): 910 | echo ASFMKV "输入路径" "[调用开关]" 911 | echo. 912 | echo 调用方法②^(CMD^): 913 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 914 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 915 | echo. 916 | echo 调用方法③: 917 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 918 | echo. 919 | echo 进程优先级: 920 | echo [0] lowest ^(最低^) 921 | echo [1] lower^(较低^) 922 | echo [2] normal^(标准^) 923 | echo [3] higher^(较高^) 924 | echo [4] highest ^(最高/实时^) 925 | echo. 926 | echo MKVmerge输出语言: 927 | echo [1] en^(English^) 928 | echo [2] zh_CN^(简体中文^) 929 | echo [3] zh_TW^(繁體中文^) 930 | echo [4] ja^(日本語^) 931 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 932 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 933 | echo 可选的语言详见"mkvmerge --ui-language list" 934 | echo. 935 | echo 文件过滤器(未经测试): 936 | echo 搜索过滤器使用标准文件搜索语法,例如: 937 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 938 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 939 | echo 其实就是如何使用通配符的问题罢了 940 | exit 941 | :show_custom_settings 942 | echo [CUSTOM SETTINGS] 943 | echo [A/Active][N/Undefined] 944 | if not defined notdel ( 945 | echo [DEL][N] 删除输入文件 946 | ) else @echo [DEL][A] 不删除输入文件 947 | if not defined notsub ( 948 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 949 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 950 | if not defined notfont ( 951 | echo [FNT][N] 不封装字体(仅嵌入字幕) 952 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 953 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 954 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 955 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 956 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 957 | if not defined searchfilter ( 958 | set "searchfilter=*" 959 | set "filter=.*" 960 | echo [FFL][N] 未使用文件过滤器 961 | ) else echo [FFL][A] 已加载文件过滤器"%searchfilter%" 962 | echo [PRI][A] 优先级"%priority%" 963 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 964 | if not "%exein%"=="mkvmerge" ( 965 | echo [EXE][A] 使用"%exein%" 966 | ) else echo [EXE][N] 使用默认程序 967 | goto :EOF -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU2.01.bat: -------------------------------------------------------------------------------- 1 | @rem !This file wrote in GB2312-80(zh-Hans) code page, do not open with other code pages. But you can even open this file with UTF-8 or UTF-16, these code pages can also show the texts! 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if not defined searchfilter goto not_replace_filter 277 | rem 正则表达式转义 278 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 279 | echo. 280 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 281 | echo [Module_ReplaceBatch] 进度0/7 282 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 283 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 284 | echo [Module_ReplaceBatch] 进度1/7 285 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 286 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 287 | echo [Module_ReplaceBatch] 进度2/7 288 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 289 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 290 | echo [Module_ReplaceBatch] 进度3/7 291 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 292 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 293 | echo [Module_ReplaceBatch] 进度4/7 294 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 295 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 296 | echo [Module_ReplaceBatch] 进度5/7 297 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 298 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 299 | echo [Module_ReplaceBatch] 进度6/7 300 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 301 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 302 | echo [Module_ReplaceBatch] 进度7/7 303 | set "filter=%replace_output%" 304 | set "replace_output=" 305 | :not_replace_filter 306 | rem 获取基本信息 307 | set "rf=%~dp0" 308 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 309 | cd /d "%rf%" 310 | rem 变更标题 311 | if not "%debug_mode%"=="0" cls 312 | title [LOAD] 正在测试mkvmerge可用性... 313 | echo [LOAD] 正在测试mkvmerge是否可用... 314 | :check_mkvmerge 315 | rem 测试MKVmerge是否可用 316 | for /f "tokens=*" %%a in ("%exein%") do ( 317 | if exist "%%~a" ( 318 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 319 | if "%%~b"=="d" ( 320 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 321 | if exist "%%~c" set "exein=%%~c" 322 | ) 323 | ) 324 | ) 325 | ) 326 | ) 327 | 328 | call "%exein%" -V>nul 2>nul 329 | 330 | if not "%errorlevel%"=="0" ( 331 | echo [ERROR] EXEIN所设置的路径无效 332 | set "errorlevel=0" 333 | ) else goto no_check_again 334 | 335 | call "mkvmerge" -V>nul 2>nul 336 | 337 | if "%errorlevel%"=="0" ( 338 | set "exein=mkvmerge" 339 | echo [CORRECT] EXEIN=mkvmerge 340 | ) else ( 341 | echo [ERROR] 无法使用MKVmerge 342 | title [ERROR] ASFMKV can't use MKVmerge 343 | exit 344 | ) 345 | :no_check_again 346 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 347 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 348 | if "%ui_language%"=="%%~a" goto uil_check_ok 349 | ) 350 | echo [ERROR] 语言"%ui_language%"不可用 351 | echo [CORRECT] 已更改为默认语言"en" 352 | set "ui_language=en" 353 | :uil_check_ok 354 | set "ver=2.01-EasyUse" 355 | if not "%debug_mode%"=="0" cls 356 | rem 获取MKVmerge的版本信息并更改标题 357 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 358 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 359 | if "%debug_mode%"=="0" ( 360 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 361 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 362 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 363 | ) 364 | rem 如果已有输入就直接执行 365 | echo. 366 | @if "%debug_mode%"=="0" echo off 367 | call :show_custom_settings 368 | @if "%debug_mode%"=="0" echo on 369 | if defined ifolder goto check_path 370 | :need_folder 371 | rem 向用户获取路径 372 | echo. 373 | set "ifolder=" 374 | set /p ifolder=文件(或目录)路径(不带引号): 375 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 376 | if not defined ifolder ( 377 | if not "%debug_mode%"=="0" cls 378 | echo [ERROR] 您没有输入任何路径! 379 | goto need_folder 380 | ) 381 | if exist "%ifolder:~1,-1%" ( 382 | set "ifolder=%ifolder:~1,-1%" 383 | ) else set "ifolder=%ifolder%" 384 | rem pause 385 | :check_path 386 | rem 如果路径不存在,则再次向用户获取 387 | if not exist "%ifolder%" ( 388 | if not "%debug_mode%"=="0" cls 389 | echo [ERROR] 路径无效! 390 | goto need_folder 391 | ) 392 | echo. 393 | :start_encode 394 | if not "%debug_mode%"=="0" cls 395 | rem 初始化变量 396 | set working=0 397 | set error=0 398 | set count=0 399 | rem 确认是目录还是文件 400 | set "dirin=" 401 | for %%a in ("%ifolder%") do ( 402 | set "attribute=%%~aa" 403 | ) 404 | if /i %attribute:~0,1%==d set "dirin=1" 405 | if not defined attribute set "dirin=1" 406 | :time_format 407 | for /f "tokens=*" %%a in ('time /T') do ( 408 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 409 | set "work_time=%%b%%c%%d" 410 | ) 411 | ) 412 | :date_format 413 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 414 | set "work_date_1=%%~a" 415 | set "work_date_2=%%~b" 416 | set "work_date_3=%%~c" 417 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 418 | if "%%~d" GTR "%%~e" ( 419 | if not "%%~e"=="" set "work_date_1=%%e" 420 | ) else if not "%%~d"=="" set "work_date_1=%%d" 421 | ) 422 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 423 | if "%%~d" GTR "%%~e" ( 424 | if not "%%~e"=="" set "work_date_2=%%e" 425 | ) else if not "%%~d"=="" set "work_date_2=%%d" 426 | ) 427 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 428 | if "%%~d" GTR "%%~e" ( 429 | if not "%%~e"=="" set "work_date_3=%%e" 430 | ) else if not "%%~d"=="" set "work_date_3=%%d" 431 | ) 432 | ) 433 | 434 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 435 | :format_del_space 436 | set "space_cache=%test_input:~-1%" 437 | if "%space_cache%"==" " ( 438 | set "test_input=%test_input:~0,-1%" 439 | ) else ( 440 | set "work_date=%test_input%" 441 | goto format_out_space_del 442 | ) 443 | goto format_del_space 444 | :format_out_space_del 445 | 446 | set "r_out_dir=%rf%[ASFMKV]redirect-output" 447 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%" 448 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%" 449 | :get_file_list 450 | rem 如果是目录则执行以下流程 451 | rem 删除先前用于记录文件列表的LOG,防止重复写入 452 | if not defined dirin ( 453 | for /f "tokens=*" %%a in ("%ifolder%") do ( 454 | cd /d "%%~dpa" 455 | set "vpath=%ifolder%" 456 | set "ifolder=%%~dpa" 457 | ) 458 | ) else cd /d "%ifolder%" 459 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 460 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 461 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 462 | echo [input.get_file_list] 正在生成运行所需的文件列表... 463 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 464 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 465 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 466 | if "%subdir%"=="0" ( 467 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 468 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 469 | if exist "%%~a" ( 470 | set /a count=count+1 471 | echo "%%~a">>"%~dp0filereader.log" 472 | ) else ( 473 | if "%ifolder:~-1%"=="\" ( 474 | call :check_path_length "%ifolder%%%~a" 475 | ) else call :check_path_length "%ifolder%\%%~a" 476 | ) 477 | ) 478 | goto INPUT_DIR_SUBDIR 479 | ) else ( 480 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 481 | set /a count=count+1 482 | echo "%%~a">>"%APPDATA%\filelist.log" 483 | ) 484 | ) 485 | goto INPUT_DIR_COUNT0 486 | :check_path_length 487 | set "path_length=%~1" 488 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 489 | goto :EOF 490 | :INPUT_DIR_SUBDIR 491 | rem 如果目标目录顶层没有文件则直接跳到下一步 492 | if %count%==0 goto INPUT_DIR_COUNT0 493 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 494 | if not defined filter goto INPUT_DIR_COUNT0 495 | set "count=0" 496 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 497 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 498 | rem 重新计数符合条件的文件 499 | if defined dirin ( 500 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 501 | ) else set count=1 502 | rem 删除临时数据记录LOG 503 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 504 | :INPUT_DIR_COUNT0 505 | rem 如果count记录的文件数为0,则报错 506 | if %count%==0 if %searchfilter%==* ( 507 | echo [ERROR] 路径为空目录! 508 | goto need_folder 509 | ) else ( 510 | echo 在路径下无法匹配到文件 511 | echo 匹配规则无效! 512 | choice /M 是否使用默认匹配规则 513 | if %errorlevel%==1 set "searchfilter=*" 514 | goto need_folder 515 | ) 516 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 517 | if exist "%~dp0filereader.log" ( 518 | rename "%~dp0filereader.log" "filelist.log" 519 | ) 520 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 521 | if defined dirin ( 522 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 523 | if exist "%%~a" ( 524 | set "vpath=%%~a" 525 | call :Module_GetOutputPath 526 | call :Module_EncapsulationMKV 527 | ) 528 | ) 529 | ) else ( 530 | rem 如果是文件则仅处理一遍 531 | call :Module_GetOutputPath 532 | call :Module_EncapsulationMKV 533 | ) 534 | :check_log_dir 535 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 536 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 537 | :ld_has_file 538 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 539 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 540 | :date_ld_has_file 541 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 542 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 543 | :Process_End 544 | title [yyfll的批量混流程序] 混流完成! 545 | if not "%debug_mode%"=="0" cls 546 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 547 | if %error% GTR 0 ( 548 | goto Has_Error 549 | ) else echo [共处理%count%项且全部处理成功] 550 | echo 任务完成! 551 | goto Batch_End 552 | :Has_Error 553 | echo [共处理%count%项,其中有%error%项未能成功处理] 554 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 555 | if "%errorlevel%"=="1" ( 556 | if exist "%logdir%" ( 557 | start %logdir% 558 | ) else echo 找不到log文件夹... 559 | echo. 560 | :Batch_End 561 | rem 删除运行所需的文件列表 562 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 563 | rem 如果是不是第三方调用则挂起 564 | if "%~1"=="" pause 565 | exit 566 | :Module_EncapsulationMKV 567 | rem 如果被其他模块要求不执行封装,则立刻退出 568 | if defined notwork set "notwork=" && goto :EOF 569 | set /a working=working+1 570 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 571 | if not "%debug_mode%"=="0" cls 572 | 573 | set "setfile=%rf%mkvmerge_settings.json" 574 | 575 | echo [Replace] 正在转义JSON...请稍等... 576 | call :Module_ReplaceBatch "%opath%" "\" "\\" 577 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 578 | (echo [ 579 | echo "-o", 580 | if not "%nul_output%"=="0" ( 581 | echo "%r_opath%", 582 | ) else echo NUL, 583 | echo "--ui-language", 584 | echo "%ui_language%", 585 | echo "-v", 586 | echo "--priority", 587 | echo "%priority%", 588 | )>"%setfile%" 589 | 590 | :GetSubtitle 591 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 592 | if not defined sub[0] goto GetFont 593 | set /a subnum=subnum-1 594 | if %subnum%==0 ( 595 | call :GetSub_Num 0 596 | set "sub[0]=" 597 | ) else ( 598 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 599 | ) 600 | goto GetFont 601 | :GetSub_Num 602 | if not defined sub[%1] goto :EOF 603 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 604 | 605 | call :Module_ReplaceBackSlash "%subname%" 606 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 607 | (echo "%%~a",)>>"%setfile%" 608 | ) 609 | set "sub[%1]=" 610 | goto :EOF 611 | :GetFont 612 | if not defined font[0] goto Start_Encapsulation 613 | set /a fontnum=fontnum-1 614 | if "%fontnum%"=="0" ( 615 | call :GetFont_Num 0 616 | set "sub[0]=" 617 | ) else ( 618 | if defined font[0] for /l %%a in (0,1,%fontnum%) do call :GetFont_Num %%a 619 | ) 620 | goto Start_Encapsulation 621 | :GetFont_Num 622 | rem 如果没有任何字体文件,则直接退出 623 | if not defined font[%1] goto :EOF 624 | rem 使用FOR读取font数组的%1项 625 | if defined font[%1] for /f "tokens=2 delims==" %%a in ('set font[%1]') do set "fontname=%%a" 626 | rem 按照字体文件的扩展名来定义附件类型 627 | for %%a in ("%fontname%") do set "fext=%%~xa" 628 | set "fext=%fext:~1%" 629 | if /i "%fext%"=="ttc" ( 630 | set "ftype=application/x-truetype-font" 631 | ) else if /i "%fext%"=="otf" ( 632 | set "ftype=application/vnd.ms-opentype" 633 | ) else if /i "%fext%"=="ttf" ( 634 | set "ftype=application/x-truetype-font" 635 | ) else set "font[%1]=" && goto GetFont_Error 636 | 637 | call :Module_ReplaceBackSlash "%fontname%" 638 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 639 | (echo "--attachment-mime-type", 640 | echo "%ftype%", 641 | echo "--attach-file", 642 | echo "%%~b",)>>"%setfile%" 643 | ) 644 | set "font[%1]=" 645 | :GetFont_Error 646 | goto :EOF 647 | :Start_Encapsulation 648 | 649 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 650 | 651 | call :Module_ReplaceBackSlash "%vpath%" 652 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 653 | (echo "%%~b", 654 | echo "--title", 655 | echo "[ASFMKV-%ver%] %filename%" 656 | echo ] 657 | )>>"%setfile%" 658 | ) 659 | 660 | if not "%debug%"=="0" cls 661 | call :show_custom_settings 662 | echo. 663 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 664 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 665 | :run_mkvmerge 666 | set "debug_file=%logdir%DEBUG-%working%.log" 667 | call "%exein%" @"%setfile%" 668 | if "%nul_output%"=="0" (set "r_level=2") else set "r_level=1" 669 | if %errorlevel% GEQ %r_level% ( 670 | set /a error=error+1 671 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 672 | call "%exein%" -r "%debug_file%" @"%setfile%" 673 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 674 | ) 675 | goto Encapsulation_OK 676 | :Encapsulation_OK 677 | if not "%nul_output%"=="0" ( 678 | if exist "%opath%" ( 679 | for %%a in ("%opath%") do set "filelen=%%~za" 680 | ) else ( 681 | set /a error=error+1 682 | goto :EOF 683 | ) 684 | ) 685 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 686 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 687 | :DelRawFile 688 | if defined notdel goto :EOF 689 | set /a filelen=filelen/1000 690 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 691 | goto :EOF 692 | :Module_ReplaceBatch 693 | if "%~1"=="" ( 694 | goto RB.error_input 695 | ) else if "%~2"=="" ( 696 | goto RB.error_input 697 | ) 698 | set "input_string=%~1" 699 | if "%input_string:~0,1%"=="" ( 700 | echo [ERROR] 您没有输入任何字符! 701 | goto RB.error_input 702 | ) 703 | set "for_delims=%~2" 704 | if "%for_delims%"=="" ( 705 | echo [ERROR] 您没有输入任何要替换的字符! 706 | goto RB.error_input 707 | ) 708 | setlocal enabledelayedexpansion 709 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 710 | if defined delims[1] ( 711 | echo [ERROR] Replace对象必须是单个字符 712 | goto RB.error_input 713 | ) 714 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 715 | if "%%~a%%~b"=="%input_string%" ( 716 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 717 | goto RB.end_clear 718 | ) 719 | ) 720 | set "replace_to=%~3" 721 | set "output_string=" 722 | set "loop=-1" 723 | :RB.re_replace 724 | set /a loop=loop+1 725 | set "RB_cache=!input_string:~%loop%,1!" 726 | if "%RB_cache%"=="" goto RB.replace_finish 727 | if "%RB_cache%"=="%for_delims%" ( 728 | set "output_string=%output_string%%replace_to%" 729 | ) else set "output_string=%output_string%%RB_cache%" 730 | goto RB.re_replace 731 | :RB.replace_finish 732 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 733 | :RB.end_clear 734 | setlocal disabledelayedexpansion 735 | set "RB_cache=" 736 | set "input_string=" 737 | set "output_string=" 738 | set "for_delims=" 739 | set "loop=" 740 | goto :EOF 741 | :RB.error_input 742 | echo [ERROR] 输入无效 743 | pause 744 | goto RB.end_clear 745 | :Module_ReplaceBackSlash 746 | if "%~1"=="" ( 747 | goto RBS.error_input 748 | ) 749 | set "input_string=A%~1A" 750 | set "for_delims=\" 751 | setlocal enabledelayedexpansion 752 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 753 | if "%%~b"=="" ( 754 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 755 | set "input_string=" 756 | set "for_delims=" 757 | goto :EOF 758 | ) 759 | ) 760 | set "replace_to=\\" 761 | set "output_string=" 762 | 763 | for /f "tokens=1 delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 764 | set "output_string=%%a" 765 | ) 766 | set "loop=1" 767 | :RBS.re_replace 768 | set /a loop=loop+1 769 | for /f "tokens=%loop% delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 770 | set "output_string=%output_string%%replace_to%%%a" 771 | goto RBS.re_replace 772 | ) 773 | echo "%output_string:~1,-1%">"%USERPROFILE%\rforbat.log" 774 | set "input_string=" 775 | set "output_string=" 776 | set "for_delims=" 777 | set "loop=" 778 | setlocal disabledelayedexpansion 779 | goto :EOF 780 | :RBS.error_input 781 | echo [ERROR] 输入无效 782 | setlocal disabledelayedexpansion 783 | pause 784 | goto :EOF 785 | :Module_GetOutputPath 786 | goto Get_Output_Path 787 | :SubNum 788 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 789 | if "%subdir%"=="0" ( 790 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 791 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 792 | for /f "tokens=*" %%b in ("%~1") do ( 793 | rem 在filelist中寻找是否有目标字幕文件 794 | if "%%~nxa"=="%%~nxb" ( 795 | rem echo "%%~a"="%%~b" 796 | set "sub[%subnum%]=%~1" 797 | set /a subnum=subnum+1 798 | goto SubNum_loop 799 | ) 800 | ) 801 | ) 802 | ) else ( 803 | set "sub[%subnum%]=%~1" 804 | set /a subnum=subnum+1 805 | ) 806 | :SubNum_loop 807 | rem pause 808 | goto :EOF 809 | :SubNum_DVDSUB 810 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 811 | call :SubNum "%~1" 812 | goto :EOF 813 | :FontNum 814 | if "%subdir%"=="0" ( 815 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 816 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 817 | for /f "tokens=*" %%b in ("%~1") do ( 818 | rem 在filelist中寻找是否有目标字体文件 819 | if "%%~nxa"=="%%~nxb" ( 820 | rem echo "%%~a"="%%~b" 821 | set "font[%fontnum%]=%~1" 822 | set /a fontnum=fontnum+1 823 | goto FontNum_loop 824 | ) 825 | ) 826 | ) 827 | ) else ( 828 | set "font[%fontnum%]=%~1" 829 | set /a fontnum=fontnum+1 830 | ) 831 | :FontNum_loop 832 | goto :EOF 833 | :Get_Output_Path 834 | for %%a in ("%vpath%") do set "ext=%%~xa" 835 | if /i %ext:~1%==mp4 ( 836 | echo.>nul 837 | ) else if /i %ext:~1%==mkv ( 838 | echo.>nul 839 | ) else if /i %ext:~1%==mpeg ( 840 | echo.>nul 841 | ) else if /i %ext:~1%==avi ( 842 | echo.>nul 843 | ) else if /i %ext:~1%==rmvb ( 844 | echo.>nul 845 | ) else if /i %ext:~1%==m4v ( 846 | echo.>nul 847 | ) else if /i %ext:~1%==flv ( 848 | echo.>nul 849 | ) else if /i %ext:~1%==wmv ( 850 | echo.>nul 851 | ) else if /i %ext:~1%==mpg ( 852 | echo.>nul 853 | ) else if /i %ext:~1%==rm ( 854 | echo.>nul 855 | ) else if /i %ext:~1%==qt ( 856 | echo.>nul 857 | ) else if /i %ext:~1%==ogg ( 858 | echo.>nul 859 | ) else if /i %ext:~1%==mov ( 860 | echo.>nul 861 | ) else if /i %ext:~1%==m2ts ( 862 | echo.>nul 863 | ) else if /i %ext:~1%==mts ( 864 | echo.>nul 865 | ) else if /i %ext:~1%==webm ( 866 | echo.>nul 867 | ) else ( 868 | set notwork=0 869 | set /a working=working+1 870 | goto :EOF 871 | ) 872 | set "test=" 873 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 874 | for %%a in ("%vpath%") do set "filename=%%~na" 875 | if defined outpath if not "%outpath%"=="" ( 876 | if not exist "%outpath%" mkdir "%outpath%">nul 877 | for %%a in ("%outpath%") do set "test=%%~aa" 878 | ) 879 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 880 | set "ostring=%outpath%%filename%" 881 | ) else set "ostring=%outpath%\%filename%" 882 | set "test=" 883 | set "subnum=0" 884 | set "fontnum=0" 885 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 886 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 887 | call :SubNum "%%~a" 888 | ) else call :SubNum_DVDSUB "%%~a" 889 | if not defined notfont goto notget_font 890 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 891 | :notget_font 892 | set "file=" 893 | if defined notsub if not defined sub[0] ( 894 | if not defined font[0] ( 895 | set "notwork=0" 896 | goto :EOF 897 | ) 898 | set "notwork=" 899 | goto Start_Get_Output_Path 900 | ) else if not defined font[0] ( 901 | set "notwork=0" 902 | goto :EOF 903 | ) 904 | if not defined sub[0] ( 905 | set "notwork=0" 906 | goto :EOF 907 | ) 908 | :Start_Get_Output_Path 909 | set "ostring=%ostring%[SUB]" 910 | set filenum=1 911 | if not exist "%ostring%.mkv" ( 912 | set "opath=%ostring%.mkv" 913 | goto :EOF 914 | ) 915 | :ReGet_Output_Path 916 | set "opath=%ostring%_%filenum%.mkv" 917 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 918 | goto :EOF 919 | :Show_Help 920 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 921 | echo Copyright(c) 2018-2019 By yyfll 922 | echo. 923 | echo 显示帮助页面(本页面)可以使用以下指令: 924 | echo Call "%~dpnx0" -h 925 | echo Call "%~dpnx0" -help 926 | echo Call "%~dpnx0" /h 927 | echo Call "%~dpnx0" /? 928 | echo. 929 | echo 调用开关: 930 | echo ?h 显示帮助^(最高优先^) 931 | echo ?del [y/n] 是否删除输入文件 932 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 933 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 934 | echo ?out [path] 输出目录 935 | echo ?dir [y/n] 是否搜索子目录 936 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 937 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 938 | echo ?ffl [filter] 文件过滤器 939 | echo ?pri [0-4] 选择进程优先级 940 | echo ?uil [1-4/input] 选择Mkvmerge的语言 941 | echo ?exe [path] 自定义MKVmerge的路径 942 | echo. 943 | echo 调用注意: 944 | echo 开关必须用引号整体括起,比如 945 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 946 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 947 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 948 | echo. 949 | echo 调用方法①^(CMD^): 950 | echo ASFMKV "输入路径" "[调用开关]" 951 | echo. 952 | echo 调用方法②^(CMD^): 953 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 954 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 955 | echo. 956 | echo 调用方法③: 957 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 958 | echo. 959 | echo 进程优先级: 960 | echo [0] lowest ^(最低^) 961 | echo [1] lower^(较低^) 962 | echo [2] normal^(标准^) 963 | echo [3] higher^(较高^) 964 | echo [4] highest ^(最高/实时^) 965 | echo. 966 | echo MKVmerge输出语言: 967 | echo [1] en^(English^) 968 | echo [2] zh_CN^(简体中文^) 969 | echo [3] zh_TW^(繁體中文^) 970 | echo [4] ja^(日本語^) 971 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 972 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 973 | echo 可选的语言详见"mkvmerge --ui-language list" 974 | echo. 975 | echo 文件过滤器(未经测试): 976 | echo 搜索过滤器使用标准文件搜索语法,例如: 977 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 978 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 979 | echo 其实就是如何使用通配符的问题罢了 980 | exit 981 | :show_custom_settings 982 | echo [CUSTOM SETTINGS] 983 | echo [A/Active][N/Undefined] 984 | if not defined notdel ( 985 | echo [DEL][N] 删除输入文件 986 | ) else @echo [DEL][A] 不删除输入文件 987 | if not defined notsub ( 988 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 989 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 990 | if not defined notfont ( 991 | echo [FNT][N] 不封装字体(仅嵌入字幕) 992 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 993 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 994 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 995 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 996 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 997 | if not defined searchfilter ( 998 | set "searchfilter=*" 999 | set "filter=.*" 1000 | echo [FFL][N] 未使用文件过滤器 1001 | ) else echo [FFL][A] 已加载文件过滤器"%searchfilter%" 1002 | echo [PRI][A] 优先级"%priority%" 1003 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 1004 | if not "%exein%"=="mkvmerge" ( 1005 | echo [EXE][A] 使用"%exein%" 1006 | ) else echo [EXE][N] 使用默认程序 1007 | goto :EOF -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU2.02.bat: -------------------------------------------------------------------------------- 1 | @rem UTF-8 without BOM file 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 277 | if not defined searchfilter goto not_replace_filter 278 | rem 正则表达式转义 279 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 280 | echo. 281 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 282 | echo [Module_ReplaceBatch] 进度0/7 283 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 284 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 285 | echo [Module_ReplaceBatch] 进度1/7 286 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 287 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 288 | echo [Module_ReplaceBatch] 进度2/7 289 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 290 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 291 | echo [Module_ReplaceBatch] 进度3/7 292 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 293 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 294 | echo [Module_ReplaceBatch] 进度4/7 295 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 296 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 297 | echo [Module_ReplaceBatch] 进度5/7 298 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 299 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 300 | echo [Module_ReplaceBatch] 进度6/7 301 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 302 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 303 | echo [Module_ReplaceBatch] 进度7/7 304 | set "filter=%replace_output%" 305 | set "replace_output=" 306 | :not_replace_filter 307 | rem 获取基本信息 308 | set "rf=%~dp0" 309 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 310 | cd /d "%rf%" 311 | rem 变更标题 312 | if not "%debug_mode%"=="0" cls 313 | title [LOAD] 正在测试mkvmerge可用性... 314 | echo [LOAD] 正在测试mkvmerge是否可用... 315 | :check_mkvmerge 316 | rem 测试MKVmerge是否可用 317 | for /f "tokens=*" %%a in ("%exein%") do ( 318 | if exist "%%~a" ( 319 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 320 | if "%%~b"=="d" ( 321 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 322 | if exist "%%~c" set "exein=%%~c" 323 | ) 324 | ) 325 | ) 326 | ) 327 | ) 328 | 329 | call "%exein%" -V>nul 2>nul 330 | 331 | if not "%errorlevel%"=="0" ( 332 | echo [ERROR] EXEIN所设置的路径无效 333 | set "errorlevel=0" 334 | ) else goto no_check_again 335 | 336 | call "mkvmerge" -V>nul 2>nul 337 | 338 | if "%errorlevel%"=="0" ( 339 | set "exein=mkvmerge" 340 | echo [CORRECT] EXEIN=mkvmerge 341 | ) else ( 342 | echo [ERROR] 无法使用MKVmerge 343 | title [ERROR] ASFMKV can't use MKVmerge 344 | exit 345 | ) 346 | :no_check_again 347 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 348 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 349 | if "%ui_language%"=="%%~a" goto uil_check_ok 350 | ) 351 | echo [ERROR] 语言"%ui_language%"不可用 352 | echo [CORRECT] 已更改为默认语言"en" 353 | set "ui_language=en" 354 | :uil_check_ok 355 | set "ver=2.02-EasyUse" 356 | if not "%debug_mode%"=="0" cls 357 | rem 获取MKVmerge的版本信息并更改标题 358 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 359 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 360 | if "%debug_mode%"=="0" ( 361 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 362 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 363 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 364 | ) 365 | rem 如果已有输入就直接执行 366 | echo. 367 | @if "%debug_mode%"=="0" echo off 368 | call :show_custom_settings 369 | @if "%debug_mode%"=="0" echo on 370 | if defined ifolder goto check_path 371 | :need_folder 372 | rem 向用户获取路径 373 | echo. 374 | set "ifolder=" 375 | set /p ifolder=文件(或目录)路径(不带引号): 376 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 377 | if not defined ifolder ( 378 | if not "%debug_mode%"=="0" cls 379 | echo [ERROR] 您没有输入任何路径! 380 | goto need_folder 381 | ) 382 | if exist "%ifolder:~1,-1%" ( 383 | set "ifolder=%ifolder:~1,-1%" 384 | ) else set "ifolder=%ifolder%" 385 | rem pause 386 | :check_path 387 | rem 如果路径不存在,则再次向用户获取 388 | if not exist "%ifolder%" ( 389 | if not "%debug_mode%"=="0" cls 390 | echo [ERROR] 路径无效! 391 | goto need_folder 392 | ) 393 | echo. 394 | :start_encode 395 | if not "%debug_mode%"=="0" cls 396 | rem 初始化变量 397 | set working=0 398 | set error=0 399 | set count=0 400 | rem 确认是目录还是文件 401 | set "dirin=" 402 | for %%a in ("%ifolder%") do ( 403 | set "attribute=%%~aa" 404 | ) 405 | if /i %attribute:~0,1%==d set "dirin=1" 406 | if not defined attribute set "dirin=1" 407 | :time_format 408 | for /f "tokens=*" %%a in ('time /T') do ( 409 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 410 | set "work_time=%%b%%c%%d" 411 | ) 412 | ) 413 | :date_format 414 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 415 | set "work_date_1=%%~a" 416 | set "work_date_2=%%~b" 417 | set "work_date_3=%%~c" 418 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 419 | if "%%~d" GTR "%%~e" ( 420 | if not "%%~e"=="" set "work_date_1=%%e" 421 | ) else if not "%%~d"=="" set "work_date_1=%%d" 422 | ) 423 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 424 | if "%%~d" GTR "%%~e" ( 425 | if not "%%~e"=="" set "work_date_2=%%e" 426 | ) else if not "%%~d"=="" set "work_date_2=%%d" 427 | ) 428 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 429 | if "%%~d" GTR "%%~e" ( 430 | if not "%%~e"=="" set "work_date_3=%%e" 431 | ) else if not "%%~d"=="" set "work_date_3=%%d" 432 | ) 433 | ) 434 | 435 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 436 | :format_del_space 437 | set "space_cache=%test_input:~-1%" 438 | if "%space_cache%"==" " ( 439 | set "test_input=%test_input:~0,-1%" 440 | ) else ( 441 | set "work_date=%test_input%" 442 | goto format_out_space_del 443 | ) 444 | goto format_del_space 445 | :format_out_space_del 446 | 447 | set "r_out_dir=%rf%[ASFMKV]redirect-output\" 448 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%\" 449 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%\" 450 | :get_file_list 451 | rem 如果是目录则执行以下流程 452 | rem 删除先前用于记录文件列表的LOG,防止重复写入 453 | if not defined dirin ( 454 | for /f "tokens=*" %%a in ("%ifolder%") do ( 455 | cd /d "%%~dpa" 456 | set "vpath=%ifolder%" 457 | set "ifolder=%%~dpa" 458 | ) 459 | ) else cd /d "%ifolder%" 460 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 461 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 462 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 463 | echo [input.get_file_list] 正在生成运行所需的文件列表... 464 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 465 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 466 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 467 | if "%subdir%"=="0" ( 468 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 469 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 470 | if exist "%%~a" ( 471 | set /a count=count+1 472 | echo "%%~a">>"%~dp0filereader.log" 473 | ) else ( 474 | if "%ifolder:~-1%"=="\" ( 475 | call :check_path_length "%ifolder%%%~a" 476 | ) else call :check_path_length "%ifolder%\%%~a" 477 | ) 478 | ) 479 | goto INPUT_DIR_SUBDIR 480 | ) else ( 481 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 482 | set /a count=count+1 483 | echo "%%~a">>"%APPDATA%\filelist.log" 484 | ) 485 | ) 486 | goto INPUT_DIR_COUNT0 487 | :check_path_length 488 | set "path_length=%~1" 489 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 490 | goto :EOF 491 | :INPUT_DIR_SUBDIR 492 | rem 如果目标目录顶层没有文件则直接跳到下一步 493 | if %count%==0 goto INPUT_DIR_COUNT0 494 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 495 | if not defined filter goto INPUT_DIR_COUNT0 496 | set "count=0" 497 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 498 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 499 | rem 重新计数符合条件的文件 500 | if defined dirin ( 501 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 502 | ) else set count=1 503 | rem 删除临时数据记录LOG 504 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 505 | :INPUT_DIR_COUNT0 506 | rem 如果count记录的文件数为0,则报错 507 | if %count%==0 if %searchfilter%==* ( 508 | echo [ERROR] 路径为空目录! 509 | goto need_folder 510 | ) else ( 511 | echo 在路径下无法匹配到文件 512 | echo 匹配规则无效! 513 | choice /M 是否使用默认匹配规则 514 | if %errorlevel%==1 set "searchfilter=*" 515 | goto need_folder 516 | ) 517 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 518 | if exist "%~dp0filereader.log" ( 519 | rename "%~dp0filereader.log" "filelist.log" 520 | ) 521 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 522 | if defined dirin ( 523 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 524 | if exist "%%~a" ( 525 | set "vpath=%%~a" 526 | call :Module_GetOutputPath 527 | call :Module_EncapsulationMKV 528 | ) 529 | ) 530 | ) else ( 531 | rem 如果是文件则仅处理一遍 532 | call :Module_GetOutputPath 533 | call :Module_EncapsulationMKV 534 | ) 535 | :check_log_dir 536 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 537 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 538 | :ld_has_file 539 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 540 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 541 | :date_ld_has_file 542 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 543 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 544 | :Process_End 545 | title [yyfll的批量混流程序] 混流完成! 546 | if not "%debug_mode%"=="0" cls 547 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 548 | if %error% GTR 0 ( 549 | goto Has_Error 550 | ) else echo [共处理%count%项且全部处理成功] 551 | echo 任务完成! 552 | goto Batch_End 553 | :Has_Error 554 | echo [共处理%count%项,其中有%error%项未能成功处理] 555 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 556 | if "%errorlevel%"=="1" ( 557 | if exist "%logdir%" ( 558 | start %logdir% 559 | ) else echo 找不到log文件夹... 560 | echo. 561 | :Batch_End 562 | rem 删除运行所需的文件列表 563 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 564 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 565 | rem 如果是不是第三方调用则挂起 566 | if "%~1"=="" pause 567 | exit 568 | :Module_EncapsulationMKV 569 | rem 如果被其他模块要求不执行封装,则立刻退出 570 | if defined notwork set "notwork=" && goto :EOF 571 | set /a working=working+1 572 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 573 | if not "%debug_mode%"=="0" cls 574 | 575 | set "setfile=%rf%mkvmerge_settings.json" 576 | 577 | echo [Replace] 正在转义JSON...请稍等... 578 | call :Module_ReplaceBackSlash "%opath%" 579 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 580 | (echo [ 581 | echo "-o", 582 | if not "%nul_output%"=="0" ( 583 | echo "%r_opath%", 584 | ) else echo "NUL", 585 | echo "--ui-language", 586 | echo "%ui_language%", 587 | echo "-v", 588 | echo "--priority", 589 | echo "%priority%",)>"%setfile%" 590 | 591 | :GetSubtitle 592 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 593 | if not defined sub[0] goto Start_Encapsulation 594 | set /a subnum=subnum-1 595 | if %subnum%==0 ( 596 | call :GetSub_Num 0 597 | set "sub[0]=" 598 | ) else ( 599 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 600 | ) 601 | goto Start_Encapsulation 602 | :GetSub_Num 603 | if not defined sub[%1] goto :EOF 604 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 605 | 606 | call :Module_ReplaceBackSlash "%subname%" 607 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 608 | (echo "%%~a",)>>"%setfile%" 609 | ) 610 | set "sub[%1]=" 611 | goto :EOF 612 | :Start_Encapsulation 613 | 614 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 615 | 616 | for /f "tokens=* usebackq" %%a in ("%rf%fonts_json.log") do ( 617 | (echo %%a)>>"%setfile%" 618 | ) 619 | 620 | call :Module_ReplaceBackSlash "%vpath%" 621 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 622 | (echo "%%~b", 623 | echo "--title", 624 | echo "[ASFMKV-%ver%] %filename%" 625 | echo ] 626 | )>>"%setfile%" 627 | ) 628 | 629 | if not "%debug%"=="0" cls 630 | call :show_custom_settings 631 | echo. 632 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 633 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 634 | :run_mkvmerge 635 | set "debug_file=%logdir%DEBUG-%working%.log" 636 | if "%nul_output%"=="0" ( 637 | set "r_level=2" 638 | ) else set "r_level=1" 639 | call "%exein%" @"%setfile%" 640 | if %errorlevel% GEQ %r_level% ( 641 | set /a error=error+1 642 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 643 | call "%exein%" -r "%debug_file%" @"%setfile%" 644 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 645 | ) 646 | goto Encapsulation_OK 647 | :Encapsulation_OK 648 | if not "%nul_output%"=="0" ( 649 | if exist "%opath%" ( 650 | for %%a in ("%opath%") do set "filelen=%%~za" 651 | ) else ( 652 | set /a error=error+1 653 | goto :EOF 654 | ) 655 | ) 656 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 657 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 658 | :DelRawFile 659 | if defined notdel goto :EOF 660 | set /a filelen=filelen/1000 661 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 662 | goto :EOF 663 | :Module_ReplaceBatch 664 | if "%~1"=="" ( 665 | goto RB.error_input 666 | ) else if "%~2"=="" ( 667 | goto RB.error_input 668 | ) 669 | set "input_string=%~1" 670 | if "%input_string:~0,1%"=="" ( 671 | echo [ERROR] 您没有输入任何字符! 672 | goto RB.error_input 673 | ) 674 | set "for_delims=%~2" 675 | if "%for_delims%"=="" ( 676 | echo [ERROR] 您没有输入任何要替换的字符! 677 | goto RB.error_input 678 | ) 679 | setlocal enabledelayedexpansion 680 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 681 | if defined delims[1] ( 682 | echo [ERROR] Replace对象必须是单个字符 683 | goto RB.error_input 684 | ) 685 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 686 | if "%%~a%%~b"=="%input_string%" ( 687 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 688 | goto RB.end_clear 689 | ) 690 | ) 691 | set "replace_to=%~3" 692 | set "output_string=" 693 | set "loop=-1" 694 | :RB.re_replace 695 | set /a loop=loop+1 696 | set "RB_cache=!input_string:~%loop%,1!" 697 | if "%RB_cache%"=="" goto RB.replace_finish 698 | if "%RB_cache%"=="%for_delims%" ( 699 | set "output_string=%output_string%%replace_to%" 700 | ) else set "output_string=%output_string%%RB_cache%" 701 | goto RB.re_replace 702 | :RB.replace_finish 703 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 704 | :RB.end_clear 705 | setlocal disabledelayedexpansion 706 | set "RB_cache=" 707 | set "input_string=" 708 | set "output_string=" 709 | set "for_delims=" 710 | set "loop=" 711 | goto :EOF 712 | :RB.error_input 713 | echo [ERROR] 输入无效 714 | pause 715 | goto RB.end_clear 716 | :Module_ReplaceBackSlash 717 | if "%~1"=="" ( 718 | goto RBS.error_input 719 | ) 720 | set "input_string=A%~1A" 721 | set "for_delims=\" 722 | setlocal enabledelayedexpansion 723 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 724 | if "%%~b"=="" ( 725 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 726 | set "input_string=" 727 | set "for_delims=" 728 | goto :EOF 729 | ) 730 | ) 731 | set "replace_to=\\" 732 | set "output_string=" 733 | 734 | for /f "tokens=1 delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 735 | set "output_string=%%a" 736 | ) 737 | set "loop=1" 738 | :RBS.re_replace 739 | set /a loop=loop+1 740 | for /f "tokens=%loop% delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 741 | set "output_string=%output_string%%replace_to%%%a" 742 | goto RBS.re_replace 743 | ) 744 | echo "%output_string:~1,-1%">"%USERPROFILE%\rforbat.log" 745 | set "input_string=" 746 | set "output_string=" 747 | set "for_delims=" 748 | set "loop=" 749 | setlocal disabledelayedexpansion 750 | goto :EOF 751 | :RBS.error_input 752 | echo [ERROR] 输入无效 753 | setlocal disabledelayedexpansion 754 | pause 755 | goto :EOF 756 | :Module_GetOutputPath 757 | goto Get_Output_Path 758 | :SubNum 759 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 760 | if "%subdir%"=="0" ( 761 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 762 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 763 | for /f "tokens=*" %%b in ("%~1") do ( 764 | rem 在filelist中寻找是否有目标字幕文件 765 | if "%%~nxa"=="%%~nxb" ( 766 | rem echo "%%~a"="%%~b" 767 | set "sub[%subnum%]=%~1" 768 | set /a subnum=subnum+1 769 | goto SubNum_loop 770 | ) 771 | ) 772 | ) 773 | ) else ( 774 | set "sub[%subnum%]=%~1" 775 | set /a subnum=subnum+1 776 | ) 777 | :SubNum_loop 778 | rem pause 779 | goto :EOF 780 | :SubNum_DVDSUB 781 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 782 | call :SubNum "%~1" 783 | goto :EOF 784 | :FontNum 785 | if "%subdir%"=="0" ( 786 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 787 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 788 | for /f "tokens=*" %%b in ("%~1") do ( 789 | rem 在filelist中寻找是否有目标字体文件 790 | if "%%~nxa"=="%%~nxb" ( 791 | set /a fontnum=fontnum+1 792 | goto FontNum_loop 793 | ) 794 | ) 795 | ) 796 | ) else ( 797 | set /a fontnum=fontnum+1 798 | goto FontNum_loop 799 | ) 800 | goto :EOF 801 | :FontNum_loop 802 | if /i "%~x1"==".ttc" ( 803 | set "ftype=application/x-truetype-font" 804 | ) else if /i "%~x1"==".otf" ( 805 | set "ftype=application/vnd.ms-opentype" 806 | ) else if /i "%~x1"==".ttf" ( 807 | set "ftype=application/x-truetype-font" 808 | ) else goto :EOF 809 | 810 | call :Module_ReplaceBackSlash "%~1" 811 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 812 | (echo "--attachment-mime-type", 813 | echo "%ftype%", 814 | echo "--attach-file", 815 | echo "%%~a",)>>"%rf%fonts_json.log" 816 | ) 817 | goto :EOF 818 | :Get_Output_Path 819 | for %%a in ("%vpath%") do set "ext=%%~xa" 820 | if /i %ext:~1%==mp4 ( 821 | echo.>nul 822 | ) else if /i %ext:~1%==mkv ( 823 | echo.>nul 824 | ) else if /i %ext:~1%==mpeg ( 825 | echo.>nul 826 | ) else if /i %ext:~1%==avi ( 827 | echo.>nul 828 | ) else if /i %ext:~1%==rmvb ( 829 | echo.>nul 830 | ) else if /i %ext:~1%==m4v ( 831 | echo.>nul 832 | ) else if /i %ext:~1%==flv ( 833 | echo.>nul 834 | ) else if /i %ext:~1%==wmv ( 835 | echo.>nul 836 | ) else if /i %ext:~1%==mpg ( 837 | echo.>nul 838 | ) else if /i %ext:~1%==rm ( 839 | echo.>nul 840 | ) else if /i %ext:~1%==qt ( 841 | echo.>nul 842 | ) else if /i %ext:~1%==ogg ( 843 | echo.>nul 844 | ) else if /i %ext:~1%==mov ( 845 | echo.>nul 846 | ) else if /i %ext:~1%==m2ts ( 847 | echo.>nul 848 | ) else if /i %ext:~1%==mts ( 849 | echo.>nul 850 | ) else if /i %ext:~1%==webm ( 851 | echo.>nul 852 | ) else ( 853 | set notwork=0 854 | set /a working=working+1 855 | goto :EOF 856 | ) 857 | set "test=" 858 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 859 | for %%a in ("%vpath%") do set "filename=%%~na" 860 | if defined outpath if not "%outpath%"=="" ( 861 | if not exist "%outpath%" mkdir "%outpath%">nul 862 | for %%a in ("%outpath%") do set "test=%%~aa" 863 | ) 864 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 865 | set "ostring=%outpath%%filename%" 866 | ) else set "ostring=%outpath%\%filename%" 867 | set "test=" 868 | set "subnum=0" 869 | set "fontnum=0" 870 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 871 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 872 | call :SubNum "%%~a" 873 | ) else call :SubNum_DVDSUB "%%~a" 874 | if not defined notfont goto notget_font 875 | 876 | if not exist "%rf%fonts_json.log" ( 877 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 878 | ) 879 | :notget_font 880 | set "file=" 881 | if defined notsub if not defined sub[0] ( 882 | if not defined font[0] ( 883 | set "notwork=0" 884 | goto :EOF 885 | ) 886 | set "notwork=" 887 | goto Start_Get_Output_Path 888 | ) else if not defined font[0] ( 889 | set "notwork=0" 890 | goto :EOF 891 | ) 892 | if not defined sub[0] ( 893 | set "notwork=0" 894 | goto :EOF 895 | ) 896 | :Start_Get_Output_Path 897 | set "ostring=%ostring%[SUB]" 898 | set filenum=1 899 | if not exist "%ostring%.mkv" ( 900 | set "opath=%ostring%.mkv" 901 | goto :EOF 902 | ) 903 | :ReGet_Output_Path 904 | set "opath=%ostring%_%filenum%.mkv" 905 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 906 | goto :EOF 907 | :Show_Help 908 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 909 | echo Copyright(c) 2018-2019 By yyfll 910 | echo. 911 | echo 显示帮助页面(本页面)可以使用以下指令: 912 | echo Call "%~dpnx0" -h 913 | echo Call "%~dpnx0" -help 914 | echo Call "%~dpnx0" /h 915 | echo Call "%~dpnx0" /? 916 | echo. 917 | echo 调用开关: 918 | echo ?h 显示帮助^(最高优先^) 919 | echo ?del [y/n] 是否删除输入文件 920 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 921 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 922 | echo ?out [path] 输出目录 923 | echo ?dir [y/n] 是否搜索子目录 924 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 925 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 926 | echo ?ffl [filter] 文件过滤器 927 | echo ?pri [0-4] 选择进程优先级 928 | echo ?uil [1-4/input] 选择Mkvmerge的语言 929 | echo ?exe [path] 自定义MKVmerge的路径 930 | echo. 931 | echo 调用注意: 932 | echo 开关必须用引号整体括起,比如 933 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 934 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 935 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 936 | echo. 937 | echo 调用方法①^(CMD^): 938 | echo ASFMKV "输入路径" "[调用开关]" 939 | echo. 940 | echo 调用方法②^(CMD^): 941 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 942 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 943 | echo. 944 | echo 调用方法③: 945 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 946 | echo. 947 | echo 进程优先级: 948 | echo [0] lowest ^(最低^) 949 | echo [1] lower^(较低^) 950 | echo [2] normal^(标准^) 951 | echo [3] higher^(较高^) 952 | echo [4] highest ^(最高/实时^) 953 | echo. 954 | echo MKVmerge输出语言: 955 | echo [1] en^(English^) 956 | echo [2] zh_CN^(简体中文^) 957 | echo [3] zh_TW^(繁體中文^) 958 | echo [4] ja^(日本語^) 959 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 960 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 961 | echo 可选的语言详见"mkvmerge --ui-language list" 962 | echo. 963 | echo 文件过滤器(未经测试): 964 | echo 搜索过滤器使用标准文件搜索语法,例如: 965 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 966 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 967 | echo 其实就是如何使用通配符的问题罢了 968 | exit 969 | :show_custom_settings 970 | echo [CUSTOM SETTINGS] 971 | echo [A/Active][N/Undefined] 972 | if not defined notdel ( 973 | echo [DEL][N] 删除输入文件 974 | ) else @echo [DEL][A] 不删除输入文件 975 | if not defined notsub ( 976 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 977 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 978 | if not defined notfont ( 979 | echo [FNT][N] 不封装字体(仅嵌入字幕) 980 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 981 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 982 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 983 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 984 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 985 | if not defined searchfilter ( 986 | set "searchfilter=*" 987 | set "filter=.*" 988 | echo [FFL][N] 未使用文件过滤器 989 | ) else ( 990 | if not "%searchfilter%"=="*" ( 991 | echo [FFL][A] 已加载文件过滤器"%searchfilter%" 992 | ) else echo [FFL][N] 未使用文件过滤器 993 | ) 994 | echo [PRI][A] 优先级"%priority%" 995 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 996 | if not "%exein%"=="mkvmerge" ( 997 | echo [EXE][A] 使用"%exein%" 998 | ) else echo [EXE][N] 使用默认程序 999 | goto :EOF -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU2.10.bat: -------------------------------------------------------------------------------- 1 | @rem UTF-8 without BOM file 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 277 | if not defined searchfilter goto not_replace_filter 278 | rem 正则表达式转义 279 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 280 | echo. 281 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 282 | echo [Module_ReplaceBatch] 进度0/7 283 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 284 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 285 | echo [Module_ReplaceBatch] 进度1/7 286 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 287 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 288 | echo [Module_ReplaceBatch] 进度2/7 289 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 290 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 291 | echo [Module_ReplaceBatch] 进度3/7 292 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 293 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 294 | echo [Module_ReplaceBatch] 进度4/7 295 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 296 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 297 | echo [Module_ReplaceBatch] 进度5/7 298 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 299 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 300 | echo [Module_ReplaceBatch] 进度6/7 301 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 302 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 303 | echo [Module_ReplaceBatch] 进度7/7 304 | set "filter=%replace_output%" 305 | set "replace_output=" 306 | :not_replace_filter 307 | rem 获取基本信息 308 | set "rf=%~dp0" 309 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 310 | cd /d "%rf%" 311 | rem 变更标题 312 | if not "%debug_mode%"=="0" cls 313 | title [LOAD] 正在测试mkvmerge可用性... 314 | echo [LOAD] 正在测试mkvmerge是否可用... 315 | :check_mkvmerge 316 | rem 测试MKVmerge是否可用 317 | for /f "tokens=*" %%a in ("%exein%") do ( 318 | if exist "%%~a" ( 319 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 320 | if "%%~b"=="d" ( 321 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 322 | if exist "%%~c" set "exein=%%~c" 323 | ) 324 | ) 325 | ) 326 | ) 327 | ) 328 | 329 | call "%exein%" -V>nul 2>nul 330 | 331 | if not "%errorlevel%"=="0" ( 332 | echo [ERROR] EXEIN所设置的路径无效 333 | set "errorlevel=0" 334 | ) else goto no_check_again 335 | 336 | call "mkvmerge" -V>nul 2>nul 337 | 338 | if "%errorlevel%"=="0" ( 339 | set "exein=mkvmerge" 340 | echo [CORRECT] EXEIN=mkvmerge 341 | ) else ( 342 | echo [ERROR] 无法使用MKVmerge 343 | title [ERROR] ASFMKV can't use MKVmerge 344 | exit 345 | ) 346 | :no_check_again 347 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 348 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 349 | if "%ui_language%"=="%%~a" goto uil_check_ok 350 | ) 351 | echo [ERROR] 语言"%ui_language%"不可用 352 | echo [CORRECT] 已更改为默认语言"en" 353 | set "ui_language=en" 354 | :uil_check_ok 355 | set "ver=2.10-EasyUse" 356 | if not "%debug_mode%"=="0" cls 357 | rem 获取MKVmerge的版本信息并更改标题 358 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 359 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 360 | if "%debug_mode%"=="0" ( 361 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 362 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 363 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 364 | ) 365 | rem 如果已有输入就直接执行 366 | echo. 367 | @if "%debug_mode%"=="0" echo off 368 | call :show_custom_settings 369 | @if "%debug_mode%"=="0" echo on 370 | if defined ifolder goto check_path 371 | :need_folder 372 | rem 向用户获取路径 373 | echo. 374 | set "ifolder=" 375 | set /p ifolder=文件(或目录)路径(不带引号): 376 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 377 | if not defined ifolder ( 378 | if not "%debug_mode%"=="0" cls 379 | echo [ERR] 您没有输入任何路径! 380 | goto need_folder 381 | ) 382 | if exist "%ifolder:~1,-1%" ( 383 | set "ifolder=%ifolder:~1,-1%" 384 | ) else set "ifolder=%ifolder%" 385 | rem pause 386 | :check_path 387 | rem 如果路径不存在,则再次向用户获取 388 | if not exist "%ifolder%" ( 389 | if not "%debug_mode%"=="0" cls 390 | call :show_setting 391 | set "ifolder=" 392 | if not defined isSetting ( 393 | echo [ERR] 输入路径无效 394 | goto need_folder 395 | ) 396 | set "isSetting=" 397 | goto uil_check_ok 398 | ) 399 | echo. 400 | :start_encode 401 | if not "%debug_mode%"=="0" cls 402 | rem 初始化变量 403 | set working=0 404 | set error=0 405 | set count=0 406 | rem 确认是目录还是文件 407 | set "dirin=" 408 | for %%a in ("%ifolder%") do ( 409 | set "attribute=%%~aa" 410 | ) 411 | if /i %attribute:~0,1%==d set "dirin=1" 412 | if not defined attribute set "dirin=1" 413 | :time_format 414 | for /f "tokens=*" %%a in ('time /T') do ( 415 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 416 | set "work_time=%%b%%c%%d" 417 | ) 418 | ) 419 | :date_format 420 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 421 | set "work_date_1=%%~a" 422 | set "work_date_2=%%~b" 423 | set "work_date_3=%%~c" 424 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 425 | if "%%~d" GTR "%%~e" ( 426 | if not "%%~e"=="" set "work_date_1=%%e" 427 | ) else if not "%%~d"=="" set "work_date_1=%%d" 428 | ) 429 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 430 | if "%%~d" GTR "%%~e" ( 431 | if not "%%~e"=="" set "work_date_2=%%e" 432 | ) else if not "%%~d"=="" set "work_date_2=%%d" 433 | ) 434 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 435 | if "%%~d" GTR "%%~e" ( 436 | if not "%%~e"=="" set "work_date_3=%%e" 437 | ) else if not "%%~d"=="" set "work_date_3=%%d" 438 | ) 439 | ) 440 | 441 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 442 | :format_del_space 443 | set "space_cache=%test_input:~-1%" 444 | if "%space_cache%"==" " ( 445 | set "test_input=%test_input:~0,-1%" 446 | ) else ( 447 | set "work_date=%test_input%" 448 | goto format_out_space_del 449 | ) 450 | goto format_del_space 451 | :format_out_space_del 452 | 453 | set "r_out_dir=%rf%[ASFMKV]redirect-output\" 454 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%\" 455 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%\" 456 | :get_file_list 457 | rem 如果是目录则执行以下流程 458 | rem 删除先前用于记录文件列表的LOG,防止重复写入 459 | if not defined dirin ( 460 | for /f "tokens=*" %%a in ("%ifolder%") do ( 461 | cd /d "%%~dpa" 462 | set "vpath=%ifolder%" 463 | set "ifolder=%%~dpa" 464 | ) 465 | ) else cd /d "%ifolder%" 466 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 467 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 468 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 469 | echo [input.get_file_list] 正在生成运行所需的文件列表... 470 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 471 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 472 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 473 | if "%subdir%"=="0" ( 474 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 475 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 476 | if exist "%%~a" ( 477 | set /a count=count+1 478 | echo "%%~a">>"%~dp0filereader.log" 479 | ) else ( 480 | if "%ifolder:~-1%"=="\" ( 481 | call :check_path_length "%ifolder%%%~a" 482 | ) else call :check_path_length "%ifolder%\%%~a" 483 | ) 484 | ) 485 | goto INPUT_DIR_SUBDIR 486 | ) else ( 487 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 488 | set /a count=count+1 489 | echo "%%~a">>"%APPDATA%\filelist.log" 490 | ) 491 | ) 492 | goto INPUT_DIR_COUNT0 493 | :check_path_length 494 | set "path_length=%~1" 495 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 496 | goto :EOF 497 | :INPUT_DIR_SUBDIR 498 | rem 如果目标目录顶层没有文件则直接跳到下一步 499 | if %count%==0 goto INPUT_DIR_COUNT0 500 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 501 | if not defined filter goto INPUT_DIR_COUNT0 502 | set "count=0" 503 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 504 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 505 | rem 重新计数符合条件的文件 506 | if defined dirin ( 507 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 508 | ) else set count=1 509 | rem 删除临时数据记录LOG 510 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 511 | :INPUT_DIR_COUNT0 512 | rem 如果count记录的文件数为0,则报错 513 | if %count%==0 if %searchfilter%==* ( 514 | echo [ERROR] 路径为空目录! 515 | goto need_folder 516 | ) else ( 517 | echo 在路径下无法匹配到文件 518 | echo 匹配规则无效! 519 | choice /M 是否使用默认匹配规则 520 | if %errorlevel%==1 set "searchfilter=*" 521 | goto need_folder 522 | ) 523 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 524 | if exist "%~dp0filereader.log" ( 525 | rename "%~dp0filereader.log" "filelist.log" 526 | ) 527 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 528 | if defined dirin ( 529 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 530 | if exist "%%~a" ( 531 | set "vpath=%%~a" 532 | call :Module_GetOutputPath 533 | call :Module_EncapsulationMKV 534 | ) 535 | ) 536 | ) else ( 537 | rem 如果是文件则仅处理一遍 538 | call :Module_GetOutputPath 539 | call :Module_EncapsulationMKV 540 | ) 541 | :check_log_dir 542 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 543 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 544 | :ld_has_file 545 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 546 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 547 | :date_ld_has_file 548 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 549 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 550 | :Process_End 551 | title [yyfll的批量混流程序] 混流完成! 552 | if not "%debug_mode%"=="0" cls 553 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 554 | if %error% GTR 0 ( 555 | goto Has_Error 556 | ) else echo [共处理%count%项且全部处理成功] 557 | echo 任务完成! 558 | goto Batch_End 559 | :Has_Error 560 | echo [共处理%count%项,其中有%error%项未能成功处理] 561 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 562 | if "%errorlevel%"=="1" ( 563 | if exist "%logdir%" ( 564 | start %logdir% 565 | ) else echo 找不到log文件夹... 566 | echo. 567 | :Batch_End 568 | rem 删除运行所需的文件列表 569 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 570 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 571 | rem 如果是不是第三方调用则挂起 572 | if "%~1"=="" pause 573 | exit 574 | :Module_EncapsulationMKV 575 | rem 如果被其他模块要求不执行封装,则立刻退出 576 | if defined notwork set "notwork=" && goto :EOF 577 | set /a working=working+1 578 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 579 | if not "%debug_mode%"=="0" cls 580 | 581 | set "setfile=%rf%mkvmerge_settings.json" 582 | 583 | echo [Replace] 正在转义JSON...请稍等... 584 | call :Module_ReplaceBackSlash "%opath%" 585 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 586 | (echo [ 587 | echo "-o", 588 | if not "%nul_output%"=="0" ( 589 | echo "%r_opath%", 590 | ) else echo "NUL", 591 | echo "--ui-language", 592 | echo "%ui_language%", 593 | echo "-v", 594 | echo "--priority", 595 | echo "%priority%",)>"%setfile%" 596 | 597 | :GetSubtitle 598 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 599 | if not defined sub[0] goto Start_Encapsulation 600 | set /a subnum=subnum-1 601 | if %subnum%==0 ( 602 | call :GetSub_Num 0 603 | set "sub[0]=" 604 | ) else ( 605 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 606 | ) 607 | goto Start_Encapsulation 608 | :GetSub_Num 609 | if not defined sub[%1] goto :EOF 610 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 611 | 612 | call :Module_ReplaceBackSlash "%subname%" 613 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 614 | (echo "%%~a",)>>"%setfile%" 615 | ) 616 | set "sub[%1]=" 617 | goto :EOF 618 | :Start_Encapsulation 619 | 620 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 621 | 622 | for /f "tokens=* usebackq" %%a in ("%rf%fonts_json.log") do ( 623 | (echo %%a)>>"%setfile%" 624 | ) 625 | 626 | call :Module_ReplaceBackSlash "%vpath%" 627 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 628 | (echo "%%~b", 629 | echo "--title", 630 | echo "[ASFMKV-%ver%] %filename%" 631 | echo ] 632 | )>>"%setfile%" 633 | ) 634 | 635 | if not "%debug%"=="0" cls 636 | call :show_custom_settings 637 | echo. 638 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 639 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 640 | :run_mkvmerge 641 | set "debug_file=%logdir%DEBUG-%working%.log" 642 | if "%nul_output%"=="0" ( 643 | set "r_level=2" 644 | ) else set "r_level=1" 645 | call "%exein%" @"%setfile%" 646 | if %errorlevel% GEQ %r_level% ( 647 | set /a error=error+1 648 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 649 | call "%exein%" -r "%debug_file%" @"%setfile%" 650 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 651 | ) 652 | goto Encapsulation_OK 653 | :Encapsulation_OK 654 | if not "%nul_output%"=="0" ( 655 | if exist "%opath%" ( 656 | for %%a in ("%opath%") do set "filelen=%%~za" 657 | ) else ( 658 | set /a error=error+1 659 | goto :EOF 660 | ) 661 | ) 662 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 663 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 664 | :DelRawFile 665 | if defined notdel goto :EOF 666 | set /a filelen=filelen/1000 667 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 668 | goto :EOF 669 | :Module_ReplaceBatch 670 | if "%~1"=="" ( 671 | goto RB.error_input 672 | ) else if "%~2"=="" ( 673 | goto RB.error_input 674 | ) 675 | set "input_string=%~1" 676 | if "%input_string:~0,1%"=="" ( 677 | echo [ERROR] 您没有输入任何字符! 678 | goto RB.error_input 679 | ) 680 | set "for_delims=%~2" 681 | if "%for_delims%"=="" ( 682 | echo [ERROR] 您没有输入任何要替换的字符! 683 | goto RB.error_input 684 | ) 685 | setlocal enabledelayedexpansion 686 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 687 | if defined delims[1] ( 688 | echo [ERROR] Replace对象必须是单个字符 689 | goto RB.error_input 690 | ) 691 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 692 | if "%%~a%%~b"=="%input_string%" ( 693 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 694 | goto RB.end_clear 695 | ) 696 | ) 697 | set "replace_to=%~3" 698 | set "output_string=" 699 | set "loop=-1" 700 | :RB.re_replace 701 | set /a loop=loop+1 702 | set "RB_cache=!input_string:~%loop%,1!" 703 | if "%RB_cache%"=="" goto RB.replace_finish 704 | if "%RB_cache%"=="%for_delims%" ( 705 | set "output_string=%output_string%%replace_to%" 706 | ) else set "output_string=%output_string%%RB_cache%" 707 | goto RB.re_replace 708 | :RB.replace_finish 709 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 710 | :RB.end_clear 711 | setlocal disabledelayedexpansion 712 | set "RB_cache=" 713 | set "input_string=" 714 | set "output_string=" 715 | set "for_delims=" 716 | set "loop=" 717 | goto :EOF 718 | :RB.error_input 719 | echo [ERROR] 输入无效 720 | pause 721 | goto RB.end_clear 722 | :Module_ReplaceBackSlash 723 | if "%~1"=="" ( 724 | goto RBS.error_input 725 | ) 726 | set "input_string=A%~1A" 727 | set "for_delims=\" 728 | setlocal enabledelayedexpansion 729 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 730 | if "%%~b"=="" ( 731 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 732 | set "input_string=" 733 | set "for_delims=" 734 | goto :EOF 735 | ) 736 | ) 737 | set "replace_to=\\" 738 | set "output_string=" 739 | 740 | for /f "tokens=1 delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 741 | set "output_string=%%a" 742 | ) 743 | set "loop=1" 744 | :RBS.re_replace 745 | set /a loop=loop+1 746 | for /f "tokens=%loop% delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 747 | set "output_string=%output_string%%replace_to%%%a" 748 | goto RBS.re_replace 749 | ) 750 | echo "%output_string:~1,-1%">"%USERPROFILE%\rforbat.log" 751 | set "input_string=" 752 | set "output_string=" 753 | set "for_delims=" 754 | set "loop=" 755 | setlocal disabledelayedexpansion 756 | goto :EOF 757 | :RBS.error_input 758 | echo [ERROR] 输入无效 759 | setlocal disabledelayedexpansion 760 | pause 761 | goto :EOF 762 | :Module_GetOutputPath 763 | goto Get_Output_Path 764 | :SubNum 765 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 766 | if "%subdir%"=="0" ( 767 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 768 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 769 | for /f "tokens=*" %%b in ("%~1") do ( 770 | rem 在filelist中寻找是否有目标字幕文件 771 | if "%%~nxa"=="%%~nxb" ( 772 | rem echo "%%~a"="%%~b" 773 | set "sub[%subnum%]=%~1" 774 | set /a subnum=subnum+1 775 | goto SubNum_loop 776 | ) 777 | ) 778 | ) 779 | ) else ( 780 | set "sub[%subnum%]=%~1" 781 | set /a subnum=subnum+1 782 | ) 783 | :SubNum_loop 784 | rem pause 785 | goto :EOF 786 | :SubNum_DVDSUB 787 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 788 | call :SubNum "%~1" 789 | goto :EOF 790 | :FontNum 791 | if "%subdir%"=="0" ( 792 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 793 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 794 | for /f "tokens=*" %%b in ("%~1") do ( 795 | rem 在filelist中寻找是否有目标字体文件 796 | if "%%~nxa"=="%%~nxb" ( 797 | set /a fontnum=fontnum+1 798 | goto FontNum_loop 799 | ) 800 | ) 801 | ) 802 | ) else ( 803 | set /a fontnum=fontnum+1 804 | goto FontNum_loop 805 | ) 806 | goto :EOF 807 | :FontNum_loop 808 | if /i "%~x1"==".ttc" ( 809 | set "ftype=application/x-truetype-font" 810 | ) else if /i "%~x1"==".otf" ( 811 | set "ftype=application/vnd.ms-opentype" 812 | ) else if /i "%~x1"==".ttf" ( 813 | set "ftype=application/x-truetype-font" 814 | ) else goto :EOF 815 | 816 | call :Module_ReplaceBackSlash "%~1" 817 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 818 | (echo "--attachment-mime-type", 819 | echo "%ftype%", 820 | echo "--attach-file", 821 | echo "%%~a",)>>"%rf%fonts_json.log" 822 | ) 823 | goto :EOF 824 | :Get_Output_Path 825 | for %%a in ("%vpath%") do set "ext=%%~xa" 826 | if /i %ext:~1%==mp4 ( 827 | echo.>nul 828 | ) else if /i %ext:~1%==mkv ( 829 | echo.>nul 830 | ) else if /i %ext:~1%==mpeg ( 831 | echo.>nul 832 | ) else if /i %ext:~1%==avi ( 833 | echo.>nul 834 | ) else if /i %ext:~1%==rmvb ( 835 | echo.>nul 836 | ) else if /i %ext:~1%==m4v ( 837 | echo.>nul 838 | ) else if /i %ext:~1%==flv ( 839 | echo.>nul 840 | ) else if /i %ext:~1%==wmv ( 841 | echo.>nul 842 | ) else if /i %ext:~1%==mpg ( 843 | echo.>nul 844 | ) else if /i %ext:~1%==rm ( 845 | echo.>nul 846 | ) else if /i %ext:~1%==qt ( 847 | echo.>nul 848 | ) else if /i %ext:~1%==ogg ( 849 | echo.>nul 850 | ) else if /i %ext:~1%==mov ( 851 | echo.>nul 852 | ) else if /i %ext:~1%==m2ts ( 853 | echo.>nul 854 | ) else if /i %ext:~1%==mts ( 855 | echo.>nul 856 | ) else if /i %ext:~1%==webm ( 857 | echo.>nul 858 | ) else ( 859 | set notwork=0 860 | set /a working=working+1 861 | goto :EOF 862 | ) 863 | set "test=" 864 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 865 | for %%a in ("%vpath%") do set "filename=%%~na" 866 | if defined outpath if not "%outpath%"=="" ( 867 | if not exist "%outpath%" mkdir "%outpath%">nul 868 | for %%a in ("%outpath%") do set "test=%%~aa" 869 | ) 870 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 871 | set "ostring=%outpath%%filename%" 872 | ) else set "ostring=%outpath%\%filename%" 873 | set "test=" 874 | set "subnum=0" 875 | set "fontnum=0" 876 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 877 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 878 | call :SubNum "%%~a" 879 | ) else call :SubNum_DVDSUB "%%~a" 880 | if not defined notfont goto notget_font 881 | 882 | if not exist "%rf%fonts_json.log" ( 883 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 884 | ) 885 | :notget_font 886 | set "file=" 887 | if defined notsub if not defined sub[0] ( 888 | if not defined font[0] ( 889 | set "notwork=0" 890 | goto :EOF 891 | ) 892 | set "notwork=" 893 | goto Start_Get_Output_Path 894 | ) else if not defined font[0] ( 895 | set "notwork=0" 896 | goto :EOF 897 | ) 898 | if not defined sub[0] ( 899 | set "notwork=0" 900 | goto :EOF 901 | ) 902 | :Start_Get_Output_Path 903 | set "ostring=%ostring%[SUB]" 904 | set filenum=1 905 | if not exist "%ostring%.mkv" ( 906 | set "opath=%ostring%.mkv" 907 | goto :EOF 908 | ) 909 | :ReGet_Output_Path 910 | set "opath=%ostring%_%filenum%.mkv" 911 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 912 | goto :EOF 913 | :Show_Help 914 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 915 | echo Copyright(c) 2018-2019 By yyfll 916 | echo. 917 | echo 显示帮助页面(本页面)可以使用以下指令: 918 | echo Call "%~dpnx0" -h 919 | echo Call "%~dpnx0" -help 920 | echo Call "%~dpnx0" /h 921 | echo Call "%~dpnx0" /? 922 | echo. 923 | echo 调用开关: 924 | echo ?h 显示帮助^(最高优先^) 925 | echo ?del [y/n] 是否删除输入文件 926 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 927 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 928 | echo ?out [path] 输出目录 929 | echo ?dir [y/n] 是否搜索子目录 930 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 931 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 932 | echo ?ffl [filter] 文件过滤器 933 | echo ?pri [0-4] 选择进程优先级 934 | echo ?uil [1-4/input] 选择Mkvmerge的语言 935 | echo ?exe [path] 自定义MKVmerge的路径 936 | echo. 937 | echo 调用注意: 938 | echo 开关必须用引号整体括起,比如 939 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 940 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 941 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 942 | echo. 943 | echo 调用方法①^(CMD^): 944 | echo ASFMKV "输入路径" "[调用开关]" 945 | echo. 946 | echo 调用方法②^(CMD^): 947 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 948 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 949 | echo. 950 | echo 调用方法③: 951 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 952 | echo. 953 | echo 进程优先级: 954 | echo [0] lowest ^(最低^) 955 | echo [1] lower^(较低^) 956 | echo [2] normal^(标准^) 957 | echo [3] higher^(较高^) 958 | echo [4] highest ^(最高/实时^) 959 | echo. 960 | echo MKVmerge输出语言: 961 | echo [1] en^(English^) 962 | echo [2] zh_CN^(简体中文^) 963 | echo [3] zh_TW^(繁體中文^) 964 | echo [4] ja^(日本語^) 965 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 966 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 967 | echo 可选的语言详见"mkvmerge --ui-language list" 968 | echo. 969 | echo 文件过滤器(未经测试): 970 | echo 搜索过滤器使用标准文件搜索语法,例如: 971 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 972 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 973 | echo 其实就是如何使用通配符的问题罢了 974 | exit 975 | :show_custom_settings 976 | echo [CUSTOM SETTINGS] 977 | echo [A/Active][N/Undefined] 978 | if not defined notdel ( 979 | echo [DEL][N] 删除输入文件 980 | ) else @echo [DEL][A] 不删除输入文件 981 | if not defined notsub ( 982 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 983 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 984 | if not defined notfont ( 985 | echo [FNT][N] 不封装字体(仅嵌入字幕) 986 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 987 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 988 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 989 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 990 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 991 | if not defined searchfilter ( 992 | set "searchfilter=*" 993 | set "filter=.*" 994 | echo [FFL][N] 未使用文件过滤器 995 | ) else ( 996 | if not "%searchfilter%"=="*" ( 997 | echo [FFL][A] 已加载文件过滤器"%searchfilter%" 998 | ) else echo [FFL][N] 未使用文件过滤器 999 | ) 1000 | echo [PRI][A] 优先级"%priority%" 1001 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 1002 | if not "%exein%"=="mkvmerge" ( 1003 | echo [EXE][A] 使用"%exein%" 1004 | ) else echo [EXE][N] 使用默认程序 1005 | goto :EOF 1006 | :show_setting 1007 | if not "%ifolder%"=="set" goto :EOF 1008 | if not "%debug_mode%"=="0" cls 1009 | cls 1010 | echo ASFMKV Settings Manager ^(ver%ver%^) 1011 | echo. 1012 | echo [可控变量] 1013 | echo [A/激活][N/未定义] 1014 | if not defined notdel ( 1015 | echo [1][N] 删除输入文件 1016 | ) else echo [1][A] 不删除输入文件 1017 | if not defined notsub ( 1018 | echo [2][N] 若没有匹配的字幕则不嵌入字体 1019 | ) else echo [2][A] 即使没有匹配到字幕也会嵌入字体 1020 | if not defined notfont ( 1021 | echo [3][N] 不封装字体(仅嵌入字幕) 1022 | ) else echo [3][A] 封装字体(同时嵌入匹配字幕与字体) 1023 | if defined outpath (echo [4][A] 输出到目录"%outpath%") else (echo [4][N] 输出到源目录) 1024 | if "%subdir%"=="0" (echo [5][A] 不搜索子目录) else (echo [5][N] 搜索子目录) 1025 | echo. 1026 | echo [特殊选项] 1027 | echo [6][B] 回到主界面 1028 | echo. 1029 | CHOICE /C 123456 /M "请选择您要调整的设定" 1030 | if "%errorlevel%"=="0" ( 1031 | cls 1032 | goto show_setting 1033 | ) else goto setting_%errorlevel% 1034 | :setting_1 1035 | if not defined notdel ( 1036 | set "notdel=1" 1037 | ) else set "notdel=" 1038 | goto show_setting 1039 | :setting_2 1040 | if not defined notsub ( 1041 | set "notsub=1" 1042 | ) else set "notsub=" 1043 | goto show_setting 1044 | :setting_3 1045 | if not defined notfont ( 1046 | set "notfont=1" 1047 | ) else set "notfont=" 1048 | goto show_setting 1049 | :setting_4 1050 | if defined outpath ( 1051 | set "outpath=" 1052 | goto show_setting 1053 | ) else ( 1054 | set /p outpath=输出路径: 1055 | ) 1056 | 1057 | if not defined outpath ( 1058 | if not "%debug_mode%"=="0" cls 1059 | echo [ERR] 您没有输入任何路径! 1060 | pause 1061 | goto show_setting 1062 | ) 1063 | 1064 | if exist "%outpath:~1,-1%" ( 1065 | set "outpath=%outpath:~1,-1%" 1066 | ) else set "outpath=%outpath%" 1067 | if not exist "%outpath%" ( 1068 | if not "%debug_mode%"=="0" cls 1069 | echo [ERR] 输入路径无效! 1070 | pause 1071 | ) 1072 | goto show_setting 1073 | :setting_5 1074 | if "%subdir%"=="0" ( 1075 | set "subdir=1" 1076 | ) else ( 1077 | set "subdir=0" 1078 | ) 1079 | goto show_setting 1080 | :setting_6 1081 | set "ifolder=" 1082 | set "isSetting=1" 1083 | goto :EOF -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EU2.11.bat: -------------------------------------------------------------------------------- 1 | @rem UTF-8 without BOM file 2 | @rem 关闭命令回显 3 | @echo off 4 | chcp 65001 5 | rem ------------------------------------------ 6 | rem 欢迎使用yyfll的批量封装程序 7 | rem 本人致力于打造傻瓜式超易用的方便的批处理程序 8 | rem 您可以致信 dyystudio@qq.com 来联系开发者 9 | rem ------------------------------------------ 10 | rem 变换标题 11 | title [初始化] 请稍等... 12 | rem ------------------------------------------ 13 | rem NotDel自定义变量 14 | rem [空] 无赋值时程序会删除混流前的源文件 15 | rem [任意] 有任意赋值时程序会保留源文件 16 | rem 语法:set "notdel=值" 17 | rem 18 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 19 | rem 20 | rem 第三方用法:[0] 值为0不删除源文件 21 | rem [-0] 值不为0删除源文件 22 | set "notdel=0" 23 | rem ------------------------------------------ 24 | rem NotSub自定义变量 25 | rem [空] 无赋值时,程序仅会在文件夹下有外挂字幕的时候才会对文件进行封装 26 | rem (若没有外挂字幕即使文件夹下有字体也会跳过该文件) 27 | rem [任意] 有任意赋值时,如果文件夹下有字体,程序会在没有外挂字幕的情况下依然封装字体到文件 28 | rem 语法:set "notsub=值" 29 | rem 30 | rem 注意:如果是第三方BAT指定了该值,将会覆盖此处的设置 31 | rem 32 | rem 第三方用法:[0] 值为0以无赋值处理 33 | rem [-0] 值不为0以任意赋值处理 34 | set "notsub=" 35 | rem ------------------------------------------ 36 | rem NotFont自定义变量 37 | rem [空] 无赋值时,程序仅会封装外挂字幕而不会封装字体文件 38 | rem [任意] 有任意赋值时,程序不仅会封装外挂字幕而且还会封装字体文件 39 | rem 语法:set "notfont=值" 40 | rem 41 | rem 该选项不允许第三方指定 42 | set "notfont=0" 43 | rem ------------------------------------------ 44 | rem OutPath自定义变量 45 | rem [空] 无赋值时,程序会将封装完成的文件输出到源文件夹 46 | rem [有效路径] 有正确赋值时,程序会将封装完成的文件输出到目标文件夹 47 | rem (路径可以为不存在的路径,程序会自动创建) 48 | rem 语法:set "outpath=值(路径不需要前后引号)" 49 | rem 50 | rem 第三方用法:[有效路径] 同上 51 | rem [无效路径] 输出到源文件夹,作无赋值处理 52 | set "outpath=" 53 | rem ------------------------------------------ 54 | rem SearchFilter自定义变量 55 | rem [空] 无赋值时,程序会使用默认值(*.*) 56 | rem [任意] 任意赋值时,若输入文件夹,程序将只封装符合匹配的文件 57 | rem 过滤器语法:可使用通配符(*),如"*.mp4"将匹配所有后缀名为MP4的文件 58 | rem 也可在文件名中使用通配符,如"*DMG*.*"将匹配所有名称中含有DMG的文件 59 | rem 语法:set "searchfilter=值" 60 | rem 61 | rem 第三方用法:[缺省] 同"空" 62 | rem [任意] 同"任意" 63 | set "searchfilter=" 64 | rem ------------------------------------------ 65 | rem MKVmerge进程优先级/界面语言 66 | rem 如果您不懂这方面的知识,请不要随意修改 67 | rem 界面语言(默认"zh_CN"(简体中文)) 68 | set "ui_language=zh_CN" 69 | rem 优先级(默认"normal"(标准)) 70 | set "priority=normal" 71 | rem ------------------------------------------ 72 | rem SubDir自定义变量 73 | rem 定义是否搜索指定目录下的子目录 74 | rem [非0] 搜索子目录 75 | rem [0] 不搜索子目录 76 | rem 77 | rem 语法:set "subdir=0" 78 | rem 79 | rem 第三方用法:[0] 同"0" 80 | rem [非0] 同"非0" 81 | set "subdir=0" 82 | rem ------------------------------------------ 83 | rem DEBUG_MODE 84 | rem 测试模式下将会关闭所有CLS并开启ECHO 85 | rem 注意!开启此项将强制开启NUL_OUTPUT! 86 | rem [0] 启用 87 | rem [非0] 停用 88 | set "debug_mode=1" 89 | rem ------------------------------------------ 90 | rem NUL_OUTPUT 91 | rem 该变量仅用于测试!请不要随意开启! 92 | rem NUL_OUTPUT开启时将会让MKVmerge把结果输出到NUL(不输出) 93 | rem 以加快测试速度并减少磁盘使用 94 | rem [0] 启用 95 | rem [非0] 停用 96 | set "nul_output=1" 97 | rem ------------------------------------------ 98 | rem EXEin 99 | rem 该变量决定运行时所用的MKVmerge的路径 100 | rem 101 | set "exein=mkvmerge" 102 | rem ------------------------------------------ 103 | rem DEBUG模块,在程序意外终止时会挂起程序 104 | cls 105 | :Module_DEBUG 106 | if not defined debug ( 107 | set debug=0 108 | cmd /c call "%~0" "%~1" "%~2%~3%~4%~5%~6%~7%~8%~9" 109 | if "%~1"=="" ( 110 | echo [Module_DEBUG] 请按任意键退出... 111 | pause>nul 112 | exit 113 | ) else ( 114 | if defined title ( 115 | title %title% 116 | ) else title Command Shell 117 | set "debug=" 118 | goto :EOF 119 | ) 120 | ) else set "debug=" 121 | rem 清屏 122 | :get_input 123 | rem EasyUse命令输入分析 124 | if /i "%~1"=="-h" goto Show_Help 125 | if /i "%~1"=="-help" goto Show_Help 126 | if /i "%~1"=="/help" goto Show_Help 127 | if /i "%~1"=="/h" goto Show_Help 128 | if /i "%~1"=="/?" goto Show_Help 129 | if /i "%~1"=="?h" goto Show_Help 130 | if not "%debug_mode%"=="0" cls 131 | if "%debug_mode%"=="0" echo on 132 | if "%~2"=="" goto not_check_input 133 | set "split_count=0" 134 | setlocal enabledelayedexpansion 135 | :split_input 136 | if defined input[%split_count%] ( 137 | for /f "tokens=1* delims==" %%a in ('set input[%split_count%]') do ( 138 | set "last_split=%%~b" 139 | ) 140 | ) 141 | set /a split_count=split_count+1 142 | for /f "tokens=%split_count% delims=?" %%a in ("%~2") do ( 143 | set "test_input=%%~a" 144 | ) 145 | if not "%test_input%"=="" ( 146 | if "%last_split%"=="%test_input%" ( 147 | set /a split_count=split_count-1 148 | set "last_split=" 149 | set "test_input=" 150 | set "space_cache=" 151 | goto split_out 152 | ) 153 | ) 154 | :del_space 155 | set "space_cache=%test_input:~-1%" 156 | if "%space_cache%"==" " ( 157 | set "test_input=!test_input:~0,-1!" 158 | ) else ( 159 | set "input[%split_count%]=%test_input%" 160 | goto out_space_del 161 | ) 162 | goto del_space 163 | :out_space_del 164 | goto split_input 165 | :split_out 166 | setlocal disabledelayedexpansion 167 | for /l %%a in (1,1,%split_count%) do ( 168 | for /f "tokens=1* delims==" %%b in ('set input[%%a]') do ( 169 | for /f "tokens=1* delims= " %%d in ("%%c") do ( 170 | 171 | if /i "%%~d"=="h" ( 172 | goto Show_Help 173 | ) 174 | 175 | if /i "%%~d"=="out" ( 176 | if exist "%%~e" ( 177 | set "outpath=%%~e" 178 | ) else if not "%%~e"=="" ( 179 | mkdir "%%~e">nul 180 | if exist "%%~e" ( 181 | set "outpath=%%~e" 182 | ) else ( 183 | echo [EasyUse Error] 输出路径无效 184 | pause 185 | exit 186 | ) 187 | ) 188 | ) 189 | 190 | if /i "%%~d"=="exe" ( 191 | if exist "%%~e" ( 192 | set "exein=%%~e" 193 | ) else set "exein=mkvmerge" 194 | ) 195 | 196 | if /i "%%~d"=="del" ( 197 | if /i "%%~e"=="y" ( 198 | set "notdel=1" 199 | ) else set "notdel=0" 200 | ) 201 | 202 | if /i "%%~d"=="sub" ( 203 | if /i "%%~e"=="y" ( 204 | set "notsub=1" 205 | set "notfont=1" 206 | ) else ( 207 | set "notsub=" 208 | ) 209 | ) 210 | 211 | if /i "%%~d"=="dir" ( 212 | if /i "%%~e"=="y" ( 213 | set "subdir=1" 214 | ) else set "subdir=0" 215 | ) 216 | 217 | if /i "%%~d"=="dbm" ( 218 | for /f "tokens=1,2 delims=:" %%f in ("%%~e") do ( 219 | if /i "%%~f"=="y" ( 220 | set "debug_mode=0" 221 | ) else set "debug_mode=1" 222 | 223 | if /i "%%~g"=="y" ( 224 | set "nul_output=0" 225 | ) else set "nul_output=1" 226 | ) 227 | ) 228 | 229 | if /i "%%~d"=="ffl" ( 230 | if not "%%~e"=="" ( 231 | set "searchfilter=%%~e" 232 | ) else set "searchfilter=" 233 | ) 234 | 235 | if /i "%%~d"=="pri" ( 236 | if "%%~e"=="0" ( 237 | set "priority=lowest" 238 | ) else if "%%~e"=="1" ( 239 | set "priority=lower" 240 | ) else if "%%~e"=="2" ( 241 | set "priority=normal" 242 | ) else if "%%~e"=="3" ( 243 | set "priority=higher" 244 | ) else if "%%~e"=="4" ( 245 | set "priority=highest" 246 | ) 247 | ) 248 | 249 | if /i "%%~d"=="uil" ( 250 | if "%%~e"=="1" ( 251 | set "ui_language=en" 252 | ) else if "%%~e"=="2" ( 253 | set "ui_language=zh_CN" 254 | ) else if "%%~e"=="3" ( 255 | set "ui_language=zh_TW" 256 | ) else if "%%~e"=="4" ( 257 | set "ui_language=ja" 258 | ) else if not "%%~e"=="" ( 259 | set "ui_language=%%~e" 260 | ) 261 | ) 262 | ) 263 | ) 264 | ) 265 | :check_input 266 | if exist "%~1" ( 267 | set "ifolder=%~1" 268 | ) else ( 269 | echo [ERROR] 输入路径有误 270 | goto Show_Help 271 | ) 272 | :not_check_input 273 | if not "%~1"=="" if exist "%~1" ( 274 | set "ifolder=%~1" 275 | ) 276 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 277 | if not defined searchfilter goto not_replace_filter 278 | rem 正则表达式转义 279 | echo [SearchFilter] 检测到文件过滤器输入...请稍等... 280 | echo. 281 | echo [Module_ReplaceBatch] 正在转义为正则表达式... 282 | echo [Module_ReplaceBatch] 进度0/7 283 | call :Module_ReplaceBatch "%searchfilter%" "." "\." 284 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 285 | echo [Module_ReplaceBatch] 进度1/7 286 | call :Module_ReplaceBatch "%replace_output%" "(" "\(" 287 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 288 | echo [Module_ReplaceBatch] 进度2/7 289 | call :Module_ReplaceBatch "%replace_output%" ")" "\)" 290 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 291 | echo [Module_ReplaceBatch] 进度3/7 292 | call :Module_ReplaceBatch "%replace_output%" "+" "\+" 293 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 294 | echo [Module_ReplaceBatch] 进度4/7 295 | call :Module_ReplaceBatch "%replace_output%" "?" "\?" 296 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 297 | echo [Module_ReplaceBatch] 进度5/7 298 | call :Module_ReplaceBatch "%replace_output%" "{" "\{" 299 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 300 | echo [Module_ReplaceBatch] 进度6/7 301 | call :Module_ReplaceBatch "%replace_output%" "*" ".*" 302 | for /f "usebackq tokens=*" %%a in ("%USERPROFILE%\rforbat.log") do set "replace_output=%%~a" 303 | echo [Module_ReplaceBatch] 进度7/7 304 | set "filter=%replace_output%" 305 | set "replace_output=" 306 | :not_replace_filter 307 | rem 获取基本信息 308 | set "rf=%~dp0" 309 | rem 定位到程序所在目录,防止以管理员模式启动导致尴尬局面 310 | cd /d "%rf%" 311 | rem 变更标题 312 | if not "%debug_mode%"=="0" cls 313 | title [LOAD] 正在测试mkvmerge可用性... 314 | echo [LOAD] 正在测试mkvmerge是否可用... 315 | :check_mkvmerge 316 | rem 测试MKVmerge是否可用 317 | for /f "tokens=*" %%a in ("%exein%") do ( 318 | if exist "%%~a" ( 319 | for /f "tokens=1 delims=-" %%b in ("%%~aa") do ( 320 | if "%%~b"=="d" ( 321 | for /r "%exein%" %%c in ("*mkvmerge*.exe") do ( 322 | if exist "%%~c" set "exein=%%~c" 323 | ) 324 | ) 325 | ) 326 | ) 327 | ) 328 | 329 | call "%exein%" -V>nul 2>nul 330 | 331 | if not "%errorlevel%"=="0" ( 332 | echo [ERROR] EXEIN所设置的路径无效 333 | set "errorlevel=0" 334 | ) else goto no_check_again 335 | 336 | call "mkvmerge" -V>nul 2>nul 337 | 338 | if "%errorlevel%"=="0" ( 339 | set "exein=mkvmerge" 340 | echo [CORRECT] EXEIN=mkvmerge 341 | ) else ( 342 | echo [ERROR] 无法使用MKVmerge 343 | title [ERROR] ASFMKV can't use MKVmerge 344 | exit 345 | ) 346 | :no_check_again 347 | echo [LOAD] 正在测试语言"%ui_language%"是否可用... 348 | for /f "skip=1 tokens=1 delims= " %%a in ('call "%exein%" --ui-language list') do ( 349 | if "%ui_language%"=="%%~a" goto uil_check_ok 350 | ) 351 | echo [ERROR] 语言"%ui_language%"不可用 352 | echo [CORRECT] 已更改为默认语言"en" 353 | set "ui_language=en" 354 | :uil_check_ok 355 | set "ver=2.11-EasyUse" 356 | if not "%debug_mode%"=="0" cls 357 | rem 获取MKVmerge的版本信息并更改标题 358 | echo [INF] ASFMKV V%ver% ^| Copyright(c) 2018-2019 yyfll 359 | for /f "tokens=1-2* delims= " %%a in ('call "%exein%" -V') do ( 360 | if "%debug_mode%"=="0" ( 361 | title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%^(DEBUG_MODE^)] 362 | ) else title AddSubFont-to-MKV [USE:%%a %%b][UTF-8][VER. %ver%] 363 | echo [USE] %%a %%b ^| Copyright^(c^) 2002-2019 Moritz Bunkus 364 | ) 365 | rem 如果已有输入就直接执行 366 | echo. 367 | @if "%debug_mode%"=="0" echo off 368 | call :show_custom_settings 369 | @if "%debug_mode%"=="0" echo on 370 | if defined ifolder goto check_path 371 | :need_folder 372 | rem 向用户获取路径 373 | echo. 374 | set "ifolder=" 375 | set /p ifolder=文件(或目录)路径(不带引号): 376 | rem 如果用户没有输入,则再次向用户获取;如果存在,则尝试去除引号 377 | if not defined ifolder ( 378 | if not "%debug_mode%"=="0" cls 379 | echo [ERR] 您没有输入任何路径! 380 | goto need_folder 381 | ) 382 | if exist "%ifolder:~1,-1%" ( 383 | set "ifolder=%ifolder:~1,-1%" 384 | ) else set "ifolder=%ifolder%" 385 | rem pause 386 | :check_path 387 | rem 如果路径不存在,则再次向用户获取 388 | if not exist "%ifolder%" ( 389 | if not "%debug_mode%"=="0" cls 390 | call :show_setting 391 | set "ifolder=" 392 | if not defined isSetting ( 393 | echo [ERR] 输入路径无效 394 | goto need_folder 395 | ) 396 | set "isSetting=" 397 | goto uil_check_ok 398 | ) 399 | echo. 400 | :start_encode 401 | if not "%debug_mode%"=="0" cls 402 | rem 初始化变量 403 | set working=0 404 | set error=0 405 | set count=0 406 | rem 确认是目录还是文件 407 | set "dirin=" 408 | for %%a in ("%ifolder%") do ( 409 | set "attribute=%%~aa" 410 | ) 411 | if /i %attribute:~0,1%==d set "dirin=1" 412 | if not defined attribute set "dirin=1" 413 | :time_format 414 | for /f "tokens=*" %%a in ('time /T') do ( 415 | for /f "delims=: tokens=1,2*" %%b in ("%%a:%time:~6,2%%time:~9,2%") do ( 416 | set "work_time=%%b%%c%%d" 417 | ) 418 | ) 419 | :date_format 420 | for /f "delims=/ tokens=1,2,3" %%a in ('date /T') do ( 421 | set "work_date_1=%%~a" 422 | set "work_date_2=%%~b" 423 | set "work_date_3=%%~c" 424 | for /f "tokens=1,2 delims= " %%d in ("%%~a") do if not "%%~d"=="%%~e" ( 425 | if "%%~d" GTR "%%~e" ( 426 | if not "%%~e"=="" set "work_date_1=%%e" 427 | ) else if not "%%~d"=="" set "work_date_1=%%d" 428 | ) 429 | for /f "tokens=1,2 delims= " %%d in ("%%~b") do if not "%%~d"=="%%~e" ( 430 | if "%%~d" GTR "%%~e" ( 431 | if not "%%~e"=="" set "work_date_2=%%e" 432 | ) else if not "%%~d"=="" set "work_date_2=%%d" 433 | ) 434 | for /f "tokens=1,2 delims= " %%d in ("%%~c") do if not "%%~d"=="%%~e" ( 435 | if "%%~d" GTR "%%~e" ( 436 | if not "%%~e"=="" set "work_date_3=%%e" 437 | ) else if not "%%~d"=="" set "work_date_3=%%d" 438 | ) 439 | ) 440 | 441 | set "test_input=%work_date_1%%work_date_2%%work_date_3%" 442 | :format_del_space 443 | set "space_cache=%test_input:~-1%" 444 | if "%space_cache%"==" " ( 445 | set "test_input=%test_input:~0,-1%" 446 | ) else ( 447 | set "work_date=%test_input%" 448 | goto format_out_space_del 449 | ) 450 | goto format_del_space 451 | :format_out_space_del 452 | 453 | set "r_out_dir=%rf%[ASFMKV]redirect-output\" 454 | set "date_logdir=%rf%[ASFMKV]redirect-output\%work_date%\" 455 | set "logdir=%rf%[ASFMKV]redirect-output\%work_date%\%work_time%\" 456 | :get_file_list 457 | rem 如果是目录则执行以下流程 458 | rem 删除先前用于记录文件列表的LOG,防止重复写入 459 | if not defined dirin ( 460 | for /f "tokens=*" %%a in ("%ifolder%") do ( 461 | cd /d "%%~dpa" 462 | set "vpath=%ifolder%" 463 | set "ifolder=%%~dpa" 464 | ) 465 | ) else cd /d "%ifolder%" 466 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 467 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 468 | title [yyfll的批量混流程序] 正在生成文件列表...请不要关闭本程序... 469 | echo [input.get_file_list] 正在生成运行所需的文件列表... 470 | rem 将符合搜索条件的文件的完整路径全部写入到filelist文件 471 | rem 如果定义了subdir变量等于0,则判断这些路径是否在目标目录而不是其子目录 472 | rem (1812TEST中为进一步减小磁盘读取压力加快速度,使用DIR+FINDSTR代替原有的FOR/R) 473 | if "%subdir%"=="0" ( 474 | rem 利用FOR循环从DIR的运行结果中获取目标目录顶层的文件 475 | for /f "tokens=*" %%a in ('dir /B /A:-D "%ifolder%"') do ( 476 | if exist "%%~a" ( 477 | set /a count=count+1 478 | echo "%%~a">>"%~dp0filereader.log" 479 | ) else ( 480 | if "%ifolder:~-1%"=="\" ( 481 | call :check_path_length "%ifolder%%%~a" 482 | ) else call :check_path_length "%ifolder%\%%~a" 483 | ) 484 | ) 485 | goto INPUT_DIR_SUBDIR 486 | ) else ( 487 | for /r "%ifolder%" %%a in ("%searchfilter%") do ( 488 | set /a count=count+1 489 | echo "%%~a">>"%APPDATA%\filelist.log" 490 | ) 491 | ) 492 | goto INPUT_DIR_COUNT0 493 | :check_path_length 494 | set "path_length=%~1" 495 | if not "%path_length:~259%"=="" echo [ERROR] 文件路径超长(260字符上限) 496 | goto :EOF 497 | :INPUT_DIR_SUBDIR 498 | rem 如果目标目录顶层没有文件则直接跳到下一步 499 | if %count%==0 goto INPUT_DIR_COUNT0 500 | rem 如果filter没有定义则直接跳到下一步(filter未定义表明不需要进行文件过滤) 501 | if not defined filter goto INPUT_DIR_COUNT0 502 | set "count=0" 503 | rem 利用findstr从已知文件中取出符合搜索过滤的文件 504 | findstr /I "%filter%" "%~dp0filereader.log">>"%APPDATA%\filelist.log" 505 | rem 重新计数符合条件的文件 506 | if defined dirin ( 507 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do set /a count=count+1 508 | ) else set count=1 509 | rem 删除临时数据记录LOG 510 | if exist "%~dp0filereader.log" del /q "%~dp0filereader.log" 511 | :INPUT_DIR_COUNT0 512 | rem 如果count记录的文件数为0,则报错 513 | if %count%==0 if %searchfilter%==* ( 514 | echo [ERROR] 路径为空目录! 515 | goto need_folder 516 | ) else ( 517 | echo 在路径下无法匹配到文件 518 | echo 匹配规则无效! 519 | choice /M 是否使用默认匹配规则 520 | if %errorlevel%==1 set "searchfilter=*" 521 | goto need_folder 522 | ) 523 | rem 删除记录记录了目标目录及其子目录中的文件路径的log文件 524 | if exist "%~dp0filereader.log" ( 525 | rename "%~dp0filereader.log" "filelist.log" 526 | ) 527 | rem 获取目标目录中的所有文件,并逐次递交负责输出路径控制、MKV封装的模块 528 | if defined dirin ( 529 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 530 | if exist "%%~a" ( 531 | set "vpath=%%~a" 532 | call :Module_GetOutputPath 533 | call :Module_EncapsulationMKV 534 | ) 535 | ) 536 | ) else ( 537 | rem 如果是文件则仅处理一遍 538 | call :Module_GetOutputPath 539 | call :Module_EncapsulationMKV 540 | ) 541 | :check_log_dir 542 | dir /A:-D-I-L /S /B "%logdir%" 1>nul 2>nul 543 | if not %errorlevel%==0 if exist "%logdir%" rmdir /S /Q "%logdir:~0,-1%" 544 | :ld_has_file 545 | dir /A:-D-I-L /S /B "%date_logdir%" 1>nul 2>nul 546 | if not %errorlevel%==0 if exist "%date_logdir%" rmdir /S /Q "%date_logdir:~0,-1%" 547 | :date_ld_has_file 548 | dir /A:-D-I-L /S /B "%r_out_dir%" 1>nul 2>nul 549 | if not %errorlevel%==0 if exist "%r_out_dir%" rmdir /S /Q "%r_out_dir:~0,-1%" 550 | :Process_End 551 | title [yyfll的批量混流程序] 混流完成! 552 | if not "%debug_mode%"=="0" cls 553 | if not "%nul_output%"=="0" if defined outpath echo [OutPath] 混流完成的文件输出到"%outpath%" 554 | if %error% GTR 0 ( 555 | goto Has_Error 556 | ) else echo [共处理%count%项且全部处理成功] 557 | echo 任务完成! 558 | goto Batch_End 559 | :Has_Error 560 | echo [共处理%count%项,其中有%error%项未能成功处理] 561 | if exist "%logdir%" CHOICE /C YN /M "是否要查看LOG文件?" 562 | if "%errorlevel%"=="1" ( 563 | if exist "%logdir%" ( 564 | start %logdir% 565 | ) else echo 找不到log文件夹... 566 | echo. 567 | :Batch_End 568 | rem 删除运行所需的文件列表 569 | if exist "%rf%fonts_json.log" del /q "%rf%fonts_json.log" 570 | if exist "%APPDATA%\filelist.log" del /q "%APPDATA%\filelist.log" 571 | rem 如果是不是第三方调用则挂起 572 | if "%~1"=="" pause 573 | if not "%~1"=="" exit 574 | goto uil_check_ok 575 | :Module_EncapsulationMKV 576 | rem 如果被其他模块要求不执行封装,则立刻退出 577 | if defined notwork set "notwork=" && goto :EOF 578 | set /a working=working+1 579 | title [yyfll的批量混流程序] 正在混流"%filename%"...(第%working%项/共%count%项) 580 | if not "%debug_mode%"=="0" cls 581 | 582 | set "setfile=%rf%mkvmerge_settings.json" 583 | 584 | echo [Replace] 正在转义JSON...请稍等... 585 | call :Module_ReplaceBackSlash "%opath%" 586 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do set "r_opath=%%~a" 587 | (echo [ 588 | echo "-o", 589 | if not "%nul_output%"=="0" ( 590 | echo "%r_opath%", 591 | ) else echo "NUL", 592 | echo "--ui-language", 593 | echo "%ui_language%", 594 | echo "-v", 595 | echo "--priority", 596 | echo "%priority%",)>"%setfile%" 597 | 598 | :GetSubtitle 599 | rem 如果没有任何字幕文件,则直接跳到字体封装预处理模块 600 | if not defined sub[0] goto Start_Encapsulation 601 | set /a subnum=subnum-1 602 | if %subnum%==0 ( 603 | call :GetSub_Num 0 604 | set "sub[0]=" 605 | ) else ( 606 | if defined sub[0] for /l %%a in (0,1,%subnum%) do call :GetSub_Num %%a 607 | ) 608 | goto Start_Encapsulation 609 | :GetSub_Num 610 | if not defined sub[%1] goto :EOF 611 | if defined sub[%1] for /f "tokens=2 delims==" %%a in ('set sub[%1]') do set "subname=%%a" 612 | 613 | call :Module_ReplaceBackSlash "%subname%" 614 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 615 | (echo "%%~a",)>>"%setfile%" 616 | ) 617 | set "sub[%1]=" 618 | goto :EOF 619 | :Start_Encapsulation 620 | 621 | if not exist "%logdir%" mkdir "%logdir%" 2>nul 622 | 623 | for /f "tokens=* usebackq" %%a in ("%rf%fonts_json.log") do ( 624 | (echo %%a)>>"%setfile%" 625 | ) 626 | 627 | call :Module_ReplaceBackSlash "%vpath%" 628 | for /f "tokens=* usebackq" %%b in ("%USERPROFILE%\rforbat.log") do ( 629 | (echo "%%~b", 630 | echo "--title", 631 | echo "[ASFMKV-%ver%] %filename%" 632 | echo ] 633 | )>>"%setfile%" 634 | ) 635 | 636 | if not "%debug%"=="0" cls 637 | call :show_custom_settings 638 | echo. 639 | rem 当nul_output为0时,将会把结果输出到NUL以在测试时不占用磁盘空间 640 | call "%exein%" -i "%vpath%" --ui-language "%ui_language%" 641 | :run_mkvmerge 642 | set "debug_file=%logdir%DEBUG-%working%.log" 643 | if "%nul_output%"=="0" ( 644 | set "r_level=2" 645 | ) else set "r_level=1" 646 | call "%exein%" @"%setfile%" 647 | if %errorlevel% GEQ %r_level% ( 648 | set /a error=error+1 649 | echo [DEBUG.mkvmerge] 正在重新运行并重定向mkvmerge输出... 650 | call "%exein%" -r "%debug_file%" @"%setfile%" 651 | move /-y "%setfile%" "%logdir%DEBUG-%working%.json" 652 | ) 653 | goto Encapsulation_OK 654 | :Encapsulation_OK 655 | if not "%nul_output%"=="0" ( 656 | if exist "%opath%" ( 657 | for %%a in ("%opath%") do set "filelen=%%~za" 658 | ) else ( 659 | set /a error=error+1 660 | goto :EOF 661 | ) 662 | ) 663 | if "%filelen%"=="0" set /a error=error+1 & del /q "%opath%" & goto :EOF 664 | if not defined notdel if exist "%vpath%" for %%a in ("%vpath%") do set /a vfilelen=%%~za/1000 665 | :DelRawFile 666 | if defined notdel goto :EOF 667 | set /a filelen=filelen/1000 668 | if %filelen% GEQ %vfilelen% del /q "%vpath%" && for %%a in ("%vpath%") do rename "%opath%" "%%~na.mkv" 669 | goto :EOF 670 | :Module_ReplaceBatch 671 | if "%~1"=="" ( 672 | goto RB.error_input 673 | ) else if "%~2"=="" ( 674 | goto RB.error_input 675 | ) 676 | set "input_string=%~1" 677 | if "%input_string:~0,1%"=="" ( 678 | echo [ERROR] 您没有输入任何字符! 679 | goto RB.error_input 680 | ) 681 | set "for_delims=%~2" 682 | if "%for_delims%"=="" ( 683 | echo [ERROR] 您没有输入任何要替换的字符! 684 | goto RB.error_input 685 | ) 686 | setlocal enabledelayedexpansion 687 | for /l %%a in (0,1,1) do set "delims[%%a]=!for_delims:~%%a!" 688 | if defined delims[1] ( 689 | echo [ERROR] Replace对象必须是单个字符 690 | goto RB.error_input 691 | ) 692 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 693 | if "%%~a%%~b"=="%input_string%" ( 694 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 695 | goto RB.end_clear 696 | ) 697 | ) 698 | set "replace_to=%~3" 699 | set "output_string=" 700 | set "loop=-1" 701 | :RB.re_replace 702 | set /a loop=loop+1 703 | set "RB_cache=!input_string:~%loop%,1!" 704 | if "%RB_cache%"=="" goto RB.replace_finish 705 | if "%RB_cache%"=="%for_delims%" ( 706 | set "output_string=%output_string%%replace_to%" 707 | ) else set "output_string=%output_string%%RB_cache%" 708 | goto RB.re_replace 709 | :RB.replace_finish 710 | echo "%output_string%">"%USERPROFILE%\rforbat.log" 711 | :RB.end_clear 712 | setlocal disabledelayedexpansion 713 | set "RB_cache=" 714 | set "input_string=" 715 | set "output_string=" 716 | set "for_delims=" 717 | set "loop=" 718 | goto :EOF 719 | :RB.error_input 720 | echo [ERROR] 输入无效 721 | pause 722 | goto RB.end_clear 723 | :Module_ReplaceBackSlash 724 | if "%~1"=="" ( 725 | goto RBS.error_input 726 | ) 727 | set "input_string=A%~1A" 728 | set "for_delims=\" 729 | setlocal enabledelayedexpansion 730 | for /f "tokens=1* delims=%for_delims%" %%a in ("%input_string%") do ( 731 | if "%%~b"=="" ( 732 | echo "%input_string:~1,-1%">"%USERPROFILE%\rforbat.log" 733 | set "input_string=" 734 | set "for_delims=" 735 | goto :EOF 736 | ) 737 | ) 738 | set "replace_to=\\" 739 | set "output_string=" 740 | 741 | for /f "tokens=1 delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 742 | set "output_string=%%a" 743 | ) 744 | set "loop=1" 745 | :RBS.re_replace 746 | set /a loop=loop+1 747 | for /f "tokens=%loop% delims=%for_delims%" %%a in ("%input_string%") do if not "%%a"=="" ( 748 | set "output_string=%output_string%%replace_to%%%a" 749 | goto RBS.re_replace 750 | ) 751 | echo "%output_string:~1,-1%">"%USERPROFILE%\rforbat.log" 752 | set "input_string=" 753 | set "output_string=" 754 | set "for_delims=" 755 | set "loop=" 756 | setlocal disabledelayedexpansion 757 | goto :EOF 758 | :RBS.error_input 759 | echo [ERROR] 输入无效 760 | setlocal disabledelayedexpansion 761 | pause 762 | goto :EOF 763 | :Module_GetOutputPath 764 | goto Get_Output_Path 765 | :SubNum 766 | rem INPUT_VALUE_1:字幕文件路径(不含扩展名) 767 | if "%subdir%"=="0" ( 768 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 769 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 770 | for /f "tokens=*" %%b in ("%~1") do ( 771 | rem 在filelist中寻找是否有目标字幕文件 772 | if "%%~nxa"=="%%~nxb" ( 773 | rem echo "%%~a"="%%~b" 774 | set "sub[%subnum%]=%~1" 775 | set /a subnum=subnum+1 776 | goto SubNum_loop 777 | ) 778 | ) 779 | ) 780 | ) else ( 781 | set "sub[%subnum%]=%~1" 782 | set /a subnum=subnum+1 783 | ) 784 | :SubNum_loop 785 | rem pause 786 | goto :EOF 787 | :SubNum_DVDSUB 788 | for %%a in ("%~1") do if not exist "%%~dpna.sub" goto :EOF 789 | call :SubNum "%~1" 790 | goto :EOF 791 | :FontNum 792 | if "%subdir%"=="0" ( 793 | rem 从1902-2开始启用subdir时直接遍历filelist而不是整个目录树,以此降低磁盘使用率 794 | for /f "usebackq tokens=*" %%a in ("%APPDATA%\filelist.log") do ( 795 | for /f "tokens=*" %%b in ("%~1") do ( 796 | rem 在filelist中寻找是否有目标字体文件 797 | if "%%~nxa"=="%%~nxb" ( 798 | set /a fontnum=fontnum+1 799 | goto FontNum_loop 800 | ) 801 | ) 802 | ) 803 | ) else ( 804 | set /a fontnum=fontnum+1 805 | goto FontNum_loop 806 | ) 807 | goto :EOF 808 | :FontNum_loop 809 | if /i "%~x1"==".ttc" ( 810 | set "ftype=application/x-truetype-font" 811 | ) else if /i "%~x1"==".otf" ( 812 | set "ftype=application/vnd.ms-opentype" 813 | ) else if /i "%~x1"==".ttf" ( 814 | set "ftype=application/x-truetype-font" 815 | ) else goto :EOF 816 | 817 | call :Module_ReplaceBackSlash "%~1" 818 | for /f "tokens=* usebackq" %%a in ("%USERPROFILE%\rforbat.log") do ( 819 | (echo "--attachment-mime-type", 820 | echo "%ftype%", 821 | echo "--attach-file", 822 | echo "%%~a",)>>"%rf%fonts_json.log" 823 | ) 824 | goto :EOF 825 | :Get_Output_Path 826 | for %%a in ("%vpath%") do set "ext=%%~xa" 827 | if /i %ext:~1%==mp4 ( 828 | echo.>nul 829 | ) else if /i %ext:~1%==mkv ( 830 | echo.>nul 831 | ) else if /i %ext:~1%==mpeg ( 832 | echo.>nul 833 | ) else if /i %ext:~1%==avi ( 834 | echo.>nul 835 | ) else if /i %ext:~1%==rmvb ( 836 | echo.>nul 837 | ) else if /i %ext:~1%==m4v ( 838 | echo.>nul 839 | ) else if /i %ext:~1%==flv ( 840 | echo.>nul 841 | ) else if /i %ext:~1%==wmv ( 842 | echo.>nul 843 | ) else if /i %ext:~1%==mpg ( 844 | echo.>nul 845 | ) else if /i %ext:~1%==rm ( 846 | echo.>nul 847 | ) else if /i %ext:~1%==qt ( 848 | echo.>nul 849 | ) else if /i %ext:~1%==ogg ( 850 | echo.>nul 851 | ) else if /i %ext:~1%==mov ( 852 | echo.>nul 853 | ) else if /i %ext:~1%==m2ts ( 854 | echo.>nul 855 | ) else if /i %ext:~1%==mts ( 856 | echo.>nul 857 | ) else if /i %ext:~1%==webm ( 858 | echo.>nul 859 | ) else ( 860 | set notwork=0 861 | set /a working=working+1 862 | goto :EOF 863 | ) 864 | set "test=" 865 | for %%a in ("%vpath%") do set "ostring=%%~dpna" 866 | for %%a in ("%vpath%") do set "filename=%%~na" 867 | if defined outpath if not "%outpath%"=="" ( 868 | if not exist "%outpath%" mkdir "%outpath%">nul 869 | for %%a in ("%outpath%") do set "test=%%~aa" 870 | ) 871 | if defined test if "%test:~0,1%"=="d" if "%test:~-1%"=="\" ( 872 | set "ostring=%outpath%%filename%" 873 | ) else set "ostring=%outpath%\%filename%" 874 | set "test=" 875 | set "subnum=0" 876 | set "fontnum=0" 877 | rem 1902-2开始不再遍历两次目录树而是直接利用if分开DVD字幕和一般字幕 878 | for /r "%ifolder%" %%a in ("*%filename%*.ass","*%filename%*.ssa","*%filename%*.srt","*%filename%*.sup","*%filename%*.idx") do if not "%%~xa"==".idx" ( 879 | call :SubNum "%%~a" 880 | ) else call :SubNum_DVDSUB "%%~a" 881 | if not defined notfont goto notget_font 882 | 883 | if not exist "%rf%fonts_json.log" ( 884 | for /r "%ifolder%" %%a in ("*.ttf","*.ttc","*.otf") do call :FontNum "%%~a" 885 | ) 886 | :notget_font 887 | set "file=" 888 | if defined notsub if not defined sub[0] ( 889 | if not defined font[0] ( 890 | set "notwork=0" 891 | goto :EOF 892 | ) 893 | set "notwork=" 894 | goto Start_Get_Output_Path 895 | ) else if not defined font[0] ( 896 | set "notwork=0" 897 | goto :EOF 898 | ) 899 | if not defined sub[0] ( 900 | set "notwork=0" 901 | goto :EOF 902 | ) 903 | :Start_Get_Output_Path 904 | set "ostring=%ostring%[SUB]" 905 | set filenum=1 906 | if not exist "%ostring%.mkv" ( 907 | set "opath=%ostring%.mkv" 908 | goto :EOF 909 | ) 910 | :ReGet_Output_Path 911 | set "opath=%ostring%_%filenum%.mkv" 912 | if exist "%opath%" set /a filenum=filenum+1 & goto ReGet_Output_Path 913 | goto :EOF 914 | :Show_Help 915 | echo Add Subtitle^&Font to MKV [EasyUse1.0] 916 | echo Copyright(c) 2018-2019 By yyfll 917 | echo. 918 | echo 显示帮助页面(本页面)可以使用以下指令: 919 | echo Call "%~dpnx0" -h 920 | echo Call "%~dpnx0" -help 921 | echo Call "%~dpnx0" /h 922 | echo Call "%~dpnx0" /? 923 | echo. 924 | echo 调用开关: 925 | echo ?h 显示帮助^(最高优先^) 926 | echo ?del [y/n] 是否删除输入文件 927 | echo ?sub [y/n] 没有字幕时是否嵌入字体文件 928 | echo ^(注意:sub开关在开启时会自动允许字体封装,即notfont为任意值^) 929 | echo ?out [path] 输出目录 930 | echo ?dir [y/n] 是否搜索子目录 931 | echo ?dbm [y/n]:[y/n] 是否使用测试模式和空输出^(测试模式开关:空输出开关^) 932 | echo ^(注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然^) 933 | echo ?ffl [filter] 文件过滤器 934 | echo ?pri [0-4] 选择进程优先级 935 | echo ?uil [1-4/input] 选择Mkvmerge的语言 936 | echo ?exe [path] 自定义MKVmerge的路径 937 | echo. 938 | echo 调用注意: 939 | echo 开关必须用引号整体括起,比如 940 | echo "?out %APPDATA%\test ?pri 3 ?dbm n:y" 941 | echo 当然你也可以使用旧输入方式(不能超过8个开关!) 942 | echo "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 943 | echo. 944 | echo 调用方法①^(CMD^): 945 | echo ASFMKV "输入路径" "[调用开关]" 946 | echo. 947 | echo 调用方法②^(CMD^): 948 | echo Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 949 | echo. ^(如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径^) 950 | echo. 951 | echo 调用方法③: 952 | echo 直接往BAT拖入文件或文件夹,自动运行重封装 953 | echo. 954 | echo 进程优先级: 955 | echo [0] lowest ^(最低^) 956 | echo [1] lower^(较低^) 957 | echo [2] normal^(标准^) 958 | echo [3] higher^(较高^) 959 | echo [4] highest ^(最高/实时^) 960 | echo. 961 | echo MKVmerge输出语言: 962 | echo [1] en^(English^) 963 | echo [2] zh_CN^(简体中文^) 964 | echo [3] zh_TW^(繁體中文^) 965 | echo [4] ja^(日本語^) 966 | echo 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 967 | echo 您也可以直接输入语言,比如 "?uil zh_CN" 968 | echo 可选的语言详见"mkvmerge --ui-language list" 969 | echo. 970 | echo 文件过滤器(未经测试): 971 | echo 搜索过滤器使用标准文件搜索语法,例如: 972 | echo "*.mkv"将只输入所有文件后缀名为MKV的文件 973 | echo "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件^(不区分大小写^)且不管后缀名是什么 974 | echo 其实就是如何使用通配符的问题罢了 975 | exit 976 | :show_custom_settings 977 | echo [CUSTOM SETTINGS] 978 | echo [A/Active][N/Undefined] 979 | if not defined notdel ( 980 | echo [DEL][N] 删除输入文件 981 | ) else @echo [DEL][A] 不删除输入文件 982 | if not defined notsub ( 983 | echo [SUB][N] 若没有匹配的字幕则不嵌入字体 984 | ) else echo [SUB][A] 即使没有匹配到字幕也会嵌入字体 985 | if not defined notfont ( 986 | echo [FNT][N] 不封装字体(仅嵌入字幕) 987 | ) else echo [FNT][A] 封装字体(同时嵌入匹配字幕与字体) 988 | if defined outpath (echo [OUT][A] 输出到目录"%outpath%") else (echo [OUT][N] 输出到源目录) 989 | if "%subdir%"=="0" (echo [DIR][A] 不搜索子目录) else (echo [DIR][N] 搜索子目录) 990 | if "%debug_mode%"=="0" (echo [DBM][A] 已启用测试模式) else (echo [DBM][N] 未使用测试模式) 991 | if "%nul_output%"=="0" (echo [NUL][A] 已启用空输出) else (echo [NUL][N] 正常输出) 992 | if not defined searchfilter ( 993 | set "searchfilter=*" 994 | set "filter=.*" 995 | echo [FFL][N] 未使用文件过滤器 996 | ) else ( 997 | if not "%searchfilter%"=="*" ( 998 | echo [FFL][A] 已加载文件过滤器"%searchfilter%" 999 | ) else echo [FFL][N] 未使用文件过滤器 1000 | ) 1001 | echo [PRI][A] 优先级"%priority%" 1002 | echo [UIL][A] MKVmerge输出语言"%ui_language%" 1003 | if not "%exein%"=="mkvmerge" ( 1004 | echo [EXE][A] 使用"%exein%" 1005 | ) else echo [EXE][N] 使用默认程序 1006 | goto :EOF 1007 | :show_setting 1008 | if not "%ifolder%"=="set" goto :EOF 1009 | if not "%debug_mode%"=="0" cls 1010 | cls 1011 | echo ASFMKV Settings Manager ^(ver%ver%^) 1012 | echo. 1013 | echo [可控变量] 1014 | echo [A/激活][N/未定义] 1015 | if not defined notdel ( 1016 | echo [1][N] 删除输入文件 1017 | ) else echo [1][A] 不删除输入文件 1018 | if not defined notsub ( 1019 | echo [2][N] 若没有匹配的字幕则不嵌入字体 1020 | ) else echo [2][A] 即使没有匹配到字幕也会嵌入字体 1021 | if not defined notfont ( 1022 | echo [3][N] 不封装字体(仅嵌入字幕) 1023 | ) else echo [3][A] 封装字体(同时嵌入匹配字幕与字体) 1024 | if defined outpath (echo [4][A] 输出到目录"%outpath%") else (echo [4][N] 输出到源目录) 1025 | if "%subdir%"=="0" (echo [5][A] 不搜索子目录) else (echo [5][N] 搜索子目录) 1026 | echo. 1027 | echo [特殊选项] 1028 | echo [6][B] 回到主界面 1029 | echo. 1030 | CHOICE /C 123456 /M "请选择您要调整的设定" 1031 | if "%errorlevel%"=="0" ( 1032 | cls 1033 | goto show_setting 1034 | ) else goto setting_%errorlevel% 1035 | :setting_1 1036 | if not defined notdel ( 1037 | set "notdel=1" 1038 | ) else set "notdel=" 1039 | goto show_setting 1040 | :setting_2 1041 | if not defined notsub ( 1042 | set "notsub=1" 1043 | ) else set "notsub=" 1044 | goto show_setting 1045 | :setting_3 1046 | if not defined notfont ( 1047 | set "notfont=1" 1048 | ) else set "notfont=" 1049 | goto show_setting 1050 | :setting_4 1051 | if defined outpath ( 1052 | set "outpath=" 1053 | goto show_setting 1054 | ) else ( 1055 | set /p outpath=输出路径: 1056 | ) 1057 | 1058 | if not defined outpath ( 1059 | if not "%debug_mode%"=="0" cls 1060 | echo [ERR] 您没有输入任何路径! 1061 | pause 1062 | goto show_setting 1063 | ) 1064 | 1065 | if exist "%outpath:~1,-1%" ( 1066 | set "outpath=%outpath:~1,-1%" 1067 | ) else set "outpath=%outpath%" 1068 | if not exist "%outpath%" ( 1069 | if not "%debug_mode%"=="0" cls 1070 | echo [ERR] 输入路径无效! 1071 | pause 1072 | ) 1073 | goto show_setting 1074 | :setting_5 1075 | if "%subdir%"=="0" ( 1076 | set "subdir=1" 1077 | ) else ( 1078 | set "subdir=0" 1079 | ) 1080 | goto show_setting 1081 | :setting_6 1082 | set "ifolder=" 1083 | set "isSetting=1" 1084 | goto :EOF -------------------------------------------------------------------------------- /ASFMKV_OLD/ASFMKV_EasyUse.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DYY-Studio/AddSubFont-to-MKV/7c150e81426a60bb348d86acc3e3aa81a481f635/ASFMKV_OLD/ASFMKV_EasyUse.bat -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AddSubFont-to-MKV(ASFMKV) 2 | - 3 | **Copyright(c) 2018-2022 yyfll(yanyifei66@gmail.com)** 4 | 5 | **本批处理是遵守GNU通用公共许可协议第二版(GPLv2)的自由软件** 6 | 7 | **本批处理是用于将字幕和字体通过MKVmerge快速封装到MKV中的无用批处理** 8 | 9 | **本批处理需要MKVmerge作为依赖** 10 | 11 | 最近更新 12 | - 13 | ### 天国的 ExtL 1.08 (很久的将来会更新) 14 | 预计完坑: 15 | 1. subdir一分为三,允许用户分别设定视频、字幕、字体的子目录搜索 16 | 17 | 预计修复: 18 | 1. 当询问用户语言时,若用户中间隔了一个不输入,则会出现语言错位的问题 19 | 2. 不再询问用户DVDSUB的语言,也不再给DVDSUB应用语言编码 20 | ### Python Remake 1.00 21 | [ASFMKV Python Remake](https://github.com/DYY-Studio/AddSubFontMKV_py) 22 | 23 | 此版本是 ASFMKV 的完全重制版本,使用 Python 编写 24 | 25 | 此版本包括以下特性: 26 | 1. 注册表字体读取 和 自定义字体文件夹读取 27 | 2. 字体内部名称读取 28 | 3. 字体查重 29 | 4. ASS/SSA 字幕文件字体依赖检查 30 | 5. 自定义变量 31 | 6. 多色高亮显示 32 | 7. 字体子集化 33 | 8. mkvmerge批量封装 34 | 35 | 目录 36 | - 37 | 38 | * 1. [为什么我不推荐直接使用ASFMKV嵌入完整字体包](#ASFMKV) 39 | * 2. [系统要求](#req) 40 | * 3. [开始混流](#-1) 41 | * 4. [格式兼容性](#-2) 42 | * 4.1. [可接受的媒体容器格式](#-2.1) 43 | * 4.2. [可接受的字幕格式](#-2.2) 44 | * 4.3. [可接受的字体格式](#-2.3) 45 | * 4.4. [输出的媒体容器格式](#-2.4) 46 | * 5. [常见问题](#-3) 47 | * 6. [自定义变量](#-4) 48 | * 6.1. [修改方式](#-4.1) 49 | * 6.2. [变量表](#-4.2) 50 | * 7. [外部调用](#-5) 51 | * 7.1. [调用开关](#-5.1) 52 | * 7.2. [开关解释](#-5.2) 53 | * 8. [挂接组件](#-6) 54 | * 9. [内部组件](#-7) 55 | 56 | 60 | 61 | 62 | 63 | ## 1. 为什么我不推荐直接使用ASFMKV嵌入完整字体包 64 | ASFMKV并没有抽取字体子集这种高级功能,这导致ASFMKV只是很单纯的把整个字体包作为附件塞在MKV文件的头部 65 | 66 | 这样做的结果就是MKV文件头部臃肿,在流视频下载头部的时候会非常吃力 67 | 68 | 整个字体包往往会比字幕所需的子集大很多,所以体积大得很没有必要 69 | 70 | 我建议各位如果有一点技术力,也请不要直接使用ASFMKV嵌入整个字体包而是抽取了字体子集再用ASFMKV嵌入 71 | 72 | *(我并没有研究过如何抽子集,应该有一键式抽取嵌入的软件,所以ASFMKV确实没什么价值)* 73 | 74 | ## 2. 系统要求 75 | * 系统:Windows 8 / 8.1 / 10 (32位/64位均兼容) 76 | 77 | *注意:Windows 7系统的用户,由于CMD版本过旧,若无法正常运行,请参考[常见问题](#-3)* 78 | * 处理器:能够正常运行Windows 79 | * 内存:能够正常运行Windows 80 | * 显卡:能够正常运行Windows 81 | * 网络:不需要 82 | * 磁盘性能:只要不卡死都无所谓。但建议持续读写速度80MB/s以上,传输速度越快处理越快(重封装说到底就是拷贝) 83 | * 磁盘空闲:10MB(视频存放盘至少需要拥有[视频大小×2+字幕+字体包大小]的空间) 84 | * 依赖组件:mkvmerge.exe必须在同一文件夹下或在%path%中的任意文件夹下 85 | 86 | *从EU1.03起,mkvmerge的路径可以在ASFMKV中设定,详见下方[自定义变量](#-4)* 87 | 88 | *注意:ExtL1.05之前的版本中,由于ASFMKV需要定位到源目录,故网络路径不受支持* 89 | 90 | 91 | 92 | ## 3. 开始混流 93 | 1. 双击打开"ASFMKV.bat" 94 | 2. 输入要混流视频所在的路径或该文件的完整路径(或从资源管理器把文件/文件夹拖入CMD窗口) 95 | 96 | > 其实你也可以直接把文件/文件夹直接拖进ASFMKV,就像拖进回收站那样 97 | 98 | 3. 等待ASFMKV生成文件列表 99 | 4. 等待MKVmerge完成混流任务 100 | 5. (可选)如果混流成功则删除源文件 101 | 102 | 103 | ## 4. 格式兼容性 104 | **以下格式兼容性是对非ExtL版本而言的,ExtL版本有内建扩展名表,用户可以自行更改,完整的支持列表见mkvmerge Doc** 105 | ### 4.1. 可接受的媒体容器格式 106 | * MKV (Matroska Video) 107 | * MP4/MPEG/M4V/MPG (MPEG) 108 | * RM/RMVB (RealMedia) 109 | * AVI (Audio Video Interleaved) 110 | * FLV (Flash Video) 111 | * WMV (Windows Media Video) 112 | * OGG (OGG) 113 | * MOV/QT (QuickTime) 114 | * M2TS (MPEG-2 Transport Stream) 115 | * WEBM (Google WebM) (1811GAMMA+支持) 116 | 117 | *** 118 | 119 | **以下格式表是内建的,不可更改** 120 | 121 | ### 4.2. 可接受的字幕格式 122 | * ASS/SSA (SubStation Alpha) 123 | * SRT (SubRip Text) 124 | * SUP/PGS (HDMV Presentation Graphic Stream Subtitles) 125 | * IDX+SUB (MPEG-4 Timed Text) 126 | 127 | ### 4.3. 可接受的字体格式 128 | * TTC/TTF (TrueType Font) 129 | * OTF (OpenType Font) 130 | 131 | ### 4.4. 输出的媒体容器格式 132 | * MKV (Matroska) 133 | 134 | ## 5. 常见问题 135 | **为什么我打不开ASFMKV?** 136 | 137 | 在 Windows 7 SP1 及更早版本的 Windows 对 `chcp`代码页切换的兼容性非常的差,以至于一切换就有可能导致崩溃。 138 | 139 | 请您用记事本打开ASFMKV,删除文件头部的 `chcp 65001`,再选择"另存为"并在下方选择以"ANSI"编码保存。 140 | 141 | 如果您有其他更好的编辑器,操作方法也是类似的,删去 `chcp 65001` 142 | 143 | 并选择使用"ANSI"编码或系统代码页(简体中文系统为"GB2312",也兼容"GB18030"、"GBK")来保存 144 | 145 | **为什么ASFMKV显示输出成功但没有任何文件输出?** 146 | 147 | 在ExtL1.03及之后的版本中,一切文件没有得到处理的原因都会在运行结束后输出在屏幕上 148 | 149 | 请检查您的输入文件夹和ASFMKV的自定义变量设定,有以下可能性: 150 | * 您的文件夹里只有字体文件而没有外挂字幕,同时您没有给NotSub变量赋值 151 | * 您的文件夹里只有字体文件,而外挂字幕在子文件夹,同时您没有给SubDir赋一个非0的值 152 | 153 | 请使用文本编辑器打开ASFMKV,修改NotSub和SubDir 154 | 155 | *(推荐兼容Batch语法高亮的编辑器,这样比较好找变量位置,如VS Code)* 156 | 157 | 或在使用EU2.10/ExtL1.00及更新版本时时在路径处输入`set`打开内置的设定管理器 158 | 159 | *(这样修改的设定并不会保存,下一次还需要再修改)* 160 | 161 | **为什么ASFMKV总是显示错误** 162 | 163 | `"mkvmerge" is not recognized as an internal or external command...` 164 | 165 | 在EU2.12f和ExtL1.02f(GitHub为ExtL1.02)前的几个版本,由于对mkvmerge检测系统的设计失误 166 | 167 | 导致找不到mkvmerge时会弹出错误而不是直接禁止继续使用 168 | 169 | 在ExtL1.03更新前的版本中,如果mkvmerge不在`path`下但和ASFMKV放在同一目录,则第一次运行时会显示检测到了mkvmerge 170 | 171 | 但运行时无法输出任何文件,第二次运行时就会显示以上错误 172 | 173 | 该问题已经在ExtL1.03中完全修复,请尽快更新 174 | 175 | ## 6. 自定义变量 176 | 为了符合不同用户的使用习惯,ASFMKV有着大量的自定义变量来符合不同用户的使用习惯 177 | 178 | ASFMKV的主界面的"[CUSTOM SETTINGS]"详细显示了各自定义变量的情况和影响 179 | 180 | ### 6.1. 修改方式 181 | 自定义变量位于ASFMKV的头部,用文本编辑器打开就能看到,每个变量都有详细的解释 182 | 183 | *推荐使用有Batch语法高亮功能的文本编辑器,如VS Code、UltraEdit,不然改起来很痛苦* 184 | 185 | 在修改的时候只需要把行首为`set`的那一行,等号后面的值修改为目标值就行了,如`set "notsub=A"`,空缺就直接`set "notsub="` 186 | 187 | **EU2.10/ExtL1.00-MG 及更新版本** 188 | 189 | 在主界面(即要求您输入文件路径、有一坨信息提示的时候)的"文件路径"处输入`set`就可以打开内置的变量管理器 190 | 191 | 使用内置变量管理器只能更改本次使用时的设定,关闭窗口即重置 192 | 193 | ### 6.2. 变量表 194 | | 变量名 | 用途 | 添加版本 | 195 | | --- | --- | --- | 196 | | ExtList | 控制ASFMKV的多媒体文件输入过滤器,决定哪些扩展名可以输入 | ExtL 1.00 | 197 | | NotDel | 控制是否要删除输入文件 | 可能 EarlyTEST | 198 | | NotSub | 控制在没有外挂字幕的时候(或者找不到外挂字幕的时候)是否要封装字体 | 2018.5 | 199 | | NotFont | 控制是否封装字体 | 2018.5 | 200 | | RmSubIn | 控制是否保留内挂字幕 | ExtL 1.06 | 201 | | RmAttach | 控制是否保留附件 | ExtL 1.06 | 202 | | OutPath | 设置文件输出路径
(ExtL1.02及之后版本均默认为"[源目录]\REMUX",其他版本都是直接输出回源目录) | ? | 203 | | sublang | 为封入的外挂字幕设置语言编码 | ExtL 1.07 | 204 | | subnote | 为封入的外挂字幕自动匹配字幕标题 | ExtL 1.07 | 205 | | SearchFilter | 使用通配符`*`、`?`来过滤输入文件 | 2018.5 | 206 | | matchStrict | 调整字幕匹配的严格程度 | ExtL 1.07 | 207 | | ui_language | 控制mkvmerge封装时显示的语言
并不更改ASFMKV的主要语言(因为只有一种语言嘛) | ? | 208 | | priority | 控制mkvmerge的进程优先级
优先级越高,被其他使用磁盘的应用阻断和干扰的程度就越小 | ? | 209 | | SubDir | 控制是否搜索子目录 | 2018.10 | 210 | | DEBUG_MODE | 启用命令回显并阻止所有CLS清屏 | 1902-3_212 | 211 | | NUL_OUTPUT | 测试用,输出到NUL(即不输出文件) | 1902-3_215 | 212 | | EXEin | mkvmerge的路径
用于mkvmerge不和ASFMKV在同一目录或不在`%path%`下的情况 | EU 1.03 | 213 | | titleVer | 是否在输出mkv文件的标题中添加ASFMKV的版本号 | ExtL 1.06 | 214 | | usingPS | 是否启用Powershell来替换内置Replace和InStr | ExtL 1.07 | 215 | 216 | 217 | ## 7. 外部调用 218 | *(全部更新至EasyUse1.0)* 219 | ### 7.1. 调用开关 220 | 221 | ?h 显示帮助(最高优先) 222 | ?del [y/n] 是否删除输入文件 223 | ?sub [y/n] 没有字幕时是否嵌入字体文件 224 | (注意:sub开关在开启时会自动允许字体封装,即notfont为任意值) 225 | ?out [path] 输出目录 226 | ?dir [y/n] 是否搜索子目录 227 | ?dbm [y/n]:[y/n] 是否使用测试模式和空输出(测试模式开关:空输出开关) 228 | (注意:dbm开关若只输入一个y则同时开启测试模式和空输出,反之亦然) 229 | ?ffl [filter] 文件过滤器 230 | ?pri [0-4] 选择进程优先级 231 | ?uil [1-4/input] 选择mkvmerge的语言 232 | ?exe [path] 选择mkvmerge的路径 233 | **调用注意** 234 | 235 | 开关必须整体,整体,整体用引号括起,比如 236 | "?out %APPDATA%\test ?pri 3 ?dbm n:y" 237 | 也可以只括起单个开关,但是这样最多只能8个开关,比如 238 | "?out %APPDATA%\test" "?pri 3" "?dbm n:y" 239 | 240 | **调用方法①(CMD)** 241 | 242 | ASFMKV "输入路径" "[调用开关]" 243 | 244 | **调用方法②(CMD)** 245 | 246 | Call "(带有某些符号的路径)\ASFMKV" "输入路径" "[调用开关]" 247 | (如果路径或文件名中含有括号、空格、与号或其他影响CMD的符号,可以使用Call指令并用双引号括起路径) 248 | 249 | **调用方法③:** 250 | 251 | 直接往BAT拖入文件或文件夹,自动运行重封装并输出到源文件夹 252 | 该情况下所有开关均为默认值 253 | 254 | ### 7.2. 开关解释 255 | 256 | **进程优先级** 257 | 258 | [0] lowest(最低) 259 | [1] lower(较低) 260 | [2] normal(标准) 261 | [3] higher(较高) 262 | [4] highest(最高/实时) 263 | 264 | 265 | **MKVmerge输出语言** 266 | 267 | 快速语言选项: 268 | [1] en(English) 269 | [2] zh_CN(简体中文) 270 | [3] zh_TW(繁體中文) 271 | [4] ja(日本語) 272 | 该语言选项仅应用于mkvmerge输出部分,并仅在支持时使用 273 | 您也可以直接输入语言,比如 "?uil zh_CN" 274 | 可选的语言详见"mkvmerge --ui-language list" 275 | 276 | **文件过滤器** 277 | 278 | 过滤器使用标准文件搜索语法,例如: 279 | "*.mkv"将只输入所有文件后缀名为MKV的文件 280 | "*SEFO*.*"将会输入所有文件名中含有"SEFO"的文件(不区分大小写)且不管后缀名是什么 281 | 其实主要就是通配符的问题罢了 282 | 283 | 284 | ## 8. 挂接组件 285 | 本BAT使用了以下挂接组件 286 | 287 | > MKVmerge(LICENSE: GPLv2) 288 | 289 | Copyright© 2002– Moritz Bunkus 290 | https://mkvtoolnix.download/downloads.html 291 | 292 | > Replace for Batch(LICENSE: MIT) 293 | 294 | Copyright© 2018-2019 yyfll(yanyifei66@gmail.com) 295 | * [Delete AND(&) (DIR Ver.)] 296 | 该版本是独立程序,用于替换文件夹下所有符合匹配并带有"&"号的文件名 297 | * [Replace for Batch V3F2_2] 298 | 使用CALL接口的泛用性Replace模块,可供挂接使用 299 | 300 | ## 9. 内部组件 301 | 本BAT使用了以下原创组件 302 | 303 | Copyright© 2018-2019 yyfll(yanyifei66@gmail.com) 304 | Module_FormatDate 日期格式化模块 305 | Module_ReplaceBackSlash [专用]JSON转义模块(EU-JSON) 306 | Module_EncapsulationMKV [专用]封装控制模块 307 | Module_GetOutputPath [专用]输出控制模块 308 | Module_DEBUG 除错辅助模块 309 | --------------------------------------------------------------------------------