
CODE: [Copy to clipboard]如果E盘根目录下正好有一个名为test.txt的文件夹,这下就热闹了:E:\test.txt下有多少个文件,E:\test.txt这个路径就会显示多少次!如果E:\test.txt下没有文件,E:\test.txt这条路径就不会有任何显示。如果test.txt这个文件夹存在于E盘的某个子文件夹中,就不会出现这样的情形。@echo off
for /f "delims=" %%i in ('dir /a-d /b /s e:\test.txt') do echo "%%~dpi"
pause
CODE: [Copy to clipboard][ Last edited by namejm on 2007-3-8 at 03:52 PM ]@echo off
for /f "delims=" %%i in ('dir /a-d /b /s e:\test.txt') do (
if /i "%%~nxi"=="test.txt" echo "%%~dpi"
)
pause
CODE: [Copy to clipboard]如果txt文件的数量巨大的话,jm的代码会要快一点@echo off
for /f "delims=" %%i in ('dir /a-d /b /s e:\*.txt') do (
if /i "%%~ni"=="test" do echo "%%~dpi"
)
pause
| Quote: | |
|
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |