本帖最后由 qixiaobin0715 于 2023-11-4 08:22 编辑
感谢14楼指出代码错误。下面代码最多可进行2次换行,即适合一行不超过90个字符,原字幕文件空行保留:- @echo off
- chcp 65001>nul
- for /f "delims=" %%i in ('dir /b /a-d *.srt') do (
- (for /f "delims=" %%j in ('type "%%i"') do (
- set "str=%%j"
- setlocal enabledelayedexpansion
- set /a t=str
- if !t! equ !str! (
- echo,%%j
- ) else if not "!str:-->=!"=="!str!" (
- echo,%%j
- ) else (
- if not "!str:~30!"=="" (
- echo,!str:~,30!
- set str=!str:~30!
- if not "!str:~30!"=="" (
- echo,!str:~,30!
- echo,!str:~30!
- echo,
- ) else (
- echo,!str!
- echo,
- )
- ) else (
- echo,%%j
- echo,
- )
- )
- endlocal
- ))>"New-%%i"
- )
复制代码
|