
CODE: [Copy to clipboard]当然,你也可以不用for来遍历,改用dir或者xcopy来打印查找的文件到一临时文件,然后根据文件内容进行操作,这种方法比较灵活,可以指定各种文件属性,不过缺点是会产生临时文件,如果不产生临时文件用for+dir或for+xcopy的话效率就不怎么样了。@echo off
pushd h:\
for /r . %%i in (*.txt) do @ren "%%i" "%%~ni.bak"
popd
CODE: [Copy to clipboard]xcopy:pushd f:\
dir /s *.txt >tmp1.txt
popd
CODE: [Copy to clipboard]得到tmp1.txt后再用for根据tmp1中的文件列表进行操作。pushd h:\
xcopy /l /s /h /f *.txt %tmp%\ >tmp1.txt
popd
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |