- @echo off
- rem 文件和批处理保存为ansi编码格式
- rem part1
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d *.srt') do (
- set n=
- for /f "delims=" %%a in ('type "%%i"') do (
- set /a n+=1,m=n%%3
- if !m! equ 1 (
- set "str1=%%a"
- ) else if !m! equ 2 (
- >>"%%~ni时间.srt" (
- echo !str1!
- echo %%a
- echo;
- )
- ) else if !m! equ 0 (
- >>"%%~ni内容.srt" (
- echo !str1!
- echo %%a
- echo;
- )
- )
- )
- )
- endlocal
- rem part2
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d *内容.srt') do (
- set /a n=0,fc=1,lengthAll=0
- for /f "delims=" %%a in ('type "%%i"') do (
- set /a n+=1,m=n%%2
- set "str=!str!%%a"
- set "str!m!=%%a"
- if !m! equ 0 (
- rem 内容.srt每单元不超100字符
- for /l %%l in (1,1,100) do (
- if defined str (
- set "str=!str:~1!"
- set lengthStr=%%l
- )
- )
- set /a lengthAll+=lengthStr
- if !lengthAll! gtr 5000 (
- set /a fc+=1,lengthAll=0
- )
- (for %%c in (1 0 #) do (
- echo,!str%%c!
- ))>>"%%~ni!fc!.srt"
- )
- )
- )
- endlocal
- pause
复制代码
试试行吗? |