It's odd - CMD doesn't respond to control C during the time it is parsing the list either.
I wrote a test which uses this batch file and it merely repeats "d:\ABC\A.BAT" a different number of times, running the batch file and measuring the elapsed time.
Code: Select all
@echo off
for %%a in (
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
"d:\ABC\A.BAT"
) do echo %%~ftzaa>>file.txt
This doesn't take as long as a real tree with long pathnames so there may be fewer buffers allocated to the shorter line.
Here is the test code:
Code: Select all
@echo off
set "file=%cd%\file.bat"
call :next 10000
call :next 30000
call :next 60000
call :next 90000
call :next 100000
call :next 150000
pause
goto :eof
:next
del file.txt 2>nul
> "%file%" echo.@echo off
>>"%file%" echo for %%%%a in ^(
for /L %%a in (1,1,%1) do (
>> "%file%" echo "%~f0"
)
>> "%file%" echo ^) do echo %%%%~ftzaa^>^>file.txt
echo running... with %1 lines
set a=%time%
call %file%
echo %a%
echo %time%
del file.txt 2>nul
goto :eof
and the results:
running... with 10000 lines ~8 seconds
4:27:01.95
4:27:09.26
running... with 30000 lines ~ 30 seconds
4:27:18.87
4:27:52.09
running... with 60000 lines ~ 1 minute 40 seconds
4:28:11.93
4:29:53.23
running... with 90000 lines ~ 3 minutes 20 seconds
4:30:23.09
4:33:48.60
running... with 100000 lines ~ 4 minutes 5 seconds
4:34:21.84
4:38:29.34
running... with 150000 lines ~ 8 minutes 35 seconds
4:39:18.96
4:47:58.85
For this next test instead of lines containing this
"d:\ABC\A.BAT"
I used this
c:\WINDOWS\Microsoft.NET\assembly\GAC_32\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll
and this was the result so parsing a list with longer elements takes a heavy toll.
running... with 10000 lines ~ 23 seconds
4:58:39.57
4:59:03.85
running... with 30000 lines ~ 2 minutes 48 seconds
4:59:12.70
5:02:00.85
running... with 60000 lines ~ 10 minutes 30 seconds
5:02:17.68
5:12:55.85
running... with 90000 lines ~ 33 minutes 20 seconds
5:13:22.78
5:36:52.89
And writing the same line 150,000 times in a separate for-in-do command takes a vastly shorter time.
5:39:17.70 ~2 minutes 40 seconds
5:41:58.37
using this code:
Code: Select all
@echo off
echo %time%
for /L %%a in (1,1,150000) do (
for %%b in ("c:\WINDOWS\Microsoft.NET\assembly\GAC_32\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll") do echo %%~ftzab>>file.txt
)
echo %time%
pause
So the upshot is that if you have a huge list then writing it in individual commands using SED etc will reduce the time taken markedly.