本帖最后由 qixiaobin0715 于 2023-11-29 11:18 编辑
回复 14# aloha20200628
读入文本空行也可采取 “(for循环 + set /p)<被读入的文件” 的方式,稍复杂些,也算是回答了13楼ShowCode的提醒。以本帖为例:- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1* delims=:" %%i in ('find /c /v "" 1.txt') do set /a n=%%j
- (for /l %%i in (1,1,!n!) do (
- set /p str=
- if not defined str (
- echo,
- ) else (
- set "str=!str!..........
- set "str=!str:,..........=!"
- set "str=!str:...........=!"
- set "str=!str:..........=!"
- echo,!str!
- set str=
- )
- ))<1.txt>2.txt
- pause
复制代码
|