本帖最后由 pcl_test 于 2015-1-23 19:47 编辑
回复 7# c755731262
如果b表示是子目录,那么在路径中也要添加- @echo off&color f0&setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b b\*.txt') do (
- set n=0
- for /f "usebackq delims=" %%j in ("b\%%i") do (
- set /a n+=1
- if !n!==2 echo %%j
- )
- )
- pause>nul
复制代码
- @echo off&color f0&setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b b\*.txt') do (
- pushd b\
- set n=0
- for /f "usebackq delims=" %%j in ("%%i") do (
- set /a n+=1
- if !n!==2 echo %%j
- )
- popd
- )
- pause>nul
复制代码
- @echo off&color f0&setlocal enabledelayedexpansion
- cd /d b\
- for /f "delims=" %%i in ('dir /b *.txt') do (
- set n=0
- for /f "usebackq delims=" %%j in ("%%i") do (
- set /a n+=1
- if !n!==2 echo %%j
- )
- )
- pause>nul
复制代码
|