本帖最后由 c755731262 于 2015-1-24 09:06 编辑
- @echo off&color f0&setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b b\*.txt') do (
- set n=0
- for /f "delims=" %%j in (%%i) do (
- set /a n+=1
- if !n!==2 echo %%j
- )
- )
- pause>nul
复制代码 而下面的代码却没问题,不知道上面的代码出错原因在哪- @echo off&color f0
- setlocal enabledelayedexpansion
- rem usebackq参数添加进去后,会把文件名里面有空格的也列举出来
- for /f "delims=" %%h in ('dir /b *.txt') do (
- set n=0
- for /f "usebackq delims=" %%i in ("%%h") do (
- set /a n+=1
- if !n!==2 (echo %%i)
- )
- )
- pause
复制代码
|