本帖最后由 qixiaobin0715 于 2021-8-2 14:54 编辑
回复 14# idwma
思路不错。但是用"tokens=1 delims=1"不妥,万一文件名中的其它地方有1的话就会出问题,修改如下:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir/b *1.txt^|findstr "[^0-9]1.txt"') do (
- set "str=%%~ni"
- set "str=!str:~0,-1!"
- for %%a in ("!str!*.txt") do set /a n+=1
- (for /l %%b in (1,1,!n!) do type !str!%%b.txt)>!str!all.txt
- set n=
- )
- pause
复制代码
|