- @echo off
- cd /d "d:\data1\"
- (type *.txt >>xxx.temp) 1>nul
- for /f "delims=" %%a in (xxx.temp) do (
- for %%b in (%%a) do (
- set/a #%%b+=1
- )
- )
- cd.>d:\data2\B.txt
- setlocal enabledelayedexpansion
- (for /f "delims=" %%a in (xxx.temp) do (
- for %%b in (%%a) do (
- if !#%%b! equ 7 (
- echo %%b
- set /a #%%b+=1
- )
- )
- ))>d:\data2\B.txt
- endlocal
- del xxx.temp
- pause
复制代码
不合并也可以,就是文本过多,可能会影响效率。昨天”优化“那个帖子代码,中间的延迟变量就是为了单独计数每个文本,去掉之后就是所有文本一起计数。
code 不合并
- @echo off
- cd /d "d:\data1\"
- for /r %%i in (*.txt) do (
- for /f "delims=" %%a in ('type "%%i"') do (
- for %%b in (%%a) do (
- set/a #%%b+=1
- )
- )
- )
- cd.>d:\data2\B.txt
- setlocal enabledelayedexpansion
- (for /r %%i in (*.txt) do (
- for /f "delims=" %%a in ('type "%%i"') do (
- for %%b in (%%a) do (
- if !#%%b! equ 7 (
- echo %%b
- set /a #%%b+=1
- )
- )
- )
- ))>d:\data2\B.txt
- endlocal
- pause
复制代码
|