Re xiaojun:
Directory traversal without using external commands? Sounds a bit like a joke.
First I'll give you a directory traversal using a recursive algorithm, only as illustrative code:
::visitdir.bat
if == call %0 \.
:main
cd %1
if exist 指定文件 指定操作
dir /ad /b > dirlist.txt
:subloop
dir dirlist.txt | find " 0" > nul
if not errorlevel 1 goto end
type nul > null.txt
fc dirlist.txt null.txt /n | find "1:" > setdir.bat
echo e 100 "set dir=">setdir.asd
echo w>>setdir.asd
echo q>>setdir.asd
debug setdir.bat nul
call setdir
call %0 %1\%dir%
find "%dir%" dirlist2.txt
copy dirlist2.txt dirlist.txt > nul
goto subloop
:end
The above program uses external commands fc, find, debug, or other string-processing tools.
※ Batchinger 致 Bat Fans:请访问
批处理编程的异类 ,欢迎交流与共享批处理编程心得!