main.bat
1 @echo off 2 color 0a 3 title Arrange m3u8 1.0 4 5 SETLOCAL ENABLEEXTENSIONS 6 SETLOCAL ENABLEDELAYEDEXPANSION 7 8 set PARAM=%~1 9 set FILE_EXT=.m3u8 10 11 if "%PARAM%" equ "" ( 12 echo Please drag and drop a ^'*%FILE_EXT%' file onto this batch program. 13 goto NORMAL_EXIT 14 ) 15 16 set FILE_NAME= 17 set SAVE_DIR= 18 19 for %%i in ("%PARAM%") do ( 20 if /i "%%~xi" neq "%FILE_EXT%" ( 21 echo Type of file must be ^'%FILE_EXT%'. 22 goto NORMAL_EXIT 23 ) 24 if /i %%~zi equ 0 ( 25 echo Error #1 26 goto NORMAL_EXIT 27 ) 28 pushd "%%~dpi" 29 set T_STR=%%~ni 30 if /i "!T_STR:~-3!" neq ".ts" ( 31 echo Error #2 32 goto NORMAL_EXIT 33 ) 34 set SAVE_DIR=!T_STR:~0,-3! 35 if "!SAVE_DIR!" equ "" ( 36 echo Error #3 37 goto NORMAL_EXIT 38 ) 39 if not exist "!SAVE_DIR!" mkdir "!SAVE_DIR!" 40 set FILE_NAME=%%~nxi 41 ) 42 for /f "usebackq eol=# tokens=1* delims=?" %%i in ("%FILE_NAME%") do ( 43 if exist "%%i" move "%%i" "%SAVE_DIR%\" 44 ) 45 46 move "%FILE_NAME%" "%SAVE_DIR%\" 47 48 :NORMAL_EXIT 49 popd 50 pause 51 exit