本帖最后由 foxJL 于 2013-11-15 11:35 编辑
回复 11# foxJL
非常感谢您的帮助!
我将所有结果都输出到一个文件b.txt中,那么代码就是- @echo off & setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b *.txt') do (
- set /p s=<%%i
- set s=!s:*-=!
- set s=!s:*-=!
- set "n="
- for /f "skip=1 delims=" %%j in (%%i) do (set /a n+=1)
- echo,0 !s! !n!>>b.txt
- more +1 %%i>>b.txt
- )
- pause
复制代码 如果我想统计该文件夹下的所有txt文件的个数,作为b.txt的第一行,该怎么办呢?- @echo off & setlocal enabledelayedexpansion
- for /f %%i in ('dir /s *.txt^|find /i "个文件"') do set num=%%i
- echo %num%>b.txt
- for /f "delims=" %%i in ('dir /b *.txt') do (
- set /p s=<%%i
- set s=!s:*-=!
- set s=!s:*-=!
- set "n="
- for /f "skip=1 delims=" %%j in (%%i) do (set /a n+=1)
- echo,0 !s! !n!>>b.txt
- more +1 %%i>>b.txt
- )
- pause
复制代码 我用这个算了下,但是b.txt文件多出来最后一行,有点不对 |