本帖最后由 Five66 于 2023-11-3 02:40 编辑
试试下面的看看吧,没有百度账号,下不了网盘文件
srt编码gbk或ansi,srt文件名不要以new_开头(因为会生成以new_开头的新的srt文件)- @echo off&chcp 936
-
- set changdu=30
-
- for %%a in (*.srt) do (
- cd.>"new_%%~na.newnew"
- set "newfile=new_%%~na.newnew"
- for /f "delims=" %%b in ('findstr /n .* "%%a"') do (
- set line=%%b
- setlocal enabledelayedexpansion
- set line=!line:*:=!
- if not defined line (
- rem echo,>>"!newfile!"
- echo,>>"!newfile!"
- ) else if "!line:~%changdu%!" == "" (
- rem echo,!line:*:=!>>"!newfile!"
- echo,!line!>>"!newfile!"
- ) else (
- set n=0
- set /a m=%changdu%
- rem set line=!line:*:=!
- call :aaa
- )
- endlocal
- )
- )
- rename *.newnew *.srt
- del *.newnew 2>nul
- echo done&pause&exit/b
-
- :aaa
- echo,!line:~%n%,%changdu%!>>"!newfile!"
- set /a n+=%changdu%
- set /a m+=%changdu%
- if "!line:~%m%!" neq "" (goto :aaa) else (
- if "!line:~%n%!" neq "" echo,!line:~%n%!>>"!newfile!"
- )
复制代码
|