只要用call方法
for /d %%d in ("%~1\*") do (set "%~2=1"&exit/b)
与
for /d /r "%~1" %%d in (*) do (set "%~2=1"&exit/b)
两个句式的耗时差约在 0.07~0.05%,二者基本相当吧。
结论还是》一方面,得益于用call方法能使纯P代码从for循环中及时退出;另一方面,跑大体量数据到其“拐点”后就“怂”了...
for /l %%a in (1,1,10) do for /l %%b in (1,1,10) do for /l %%c in (1,1,10) do for /l %%d in (1,1,10) do for /l %%e in (1,1,10) do md test\%%a\%%b\%%c\%%d\%%e\ 2>nul