I did two tests in speed of getting file size into a variable. Both solutions are here on DOSTIPS somewhere.
First uses FINDSTR, the second uses FOR with %~z.
The test code creates new file (with a new filename and new content to minimize the caching (probably). Gettimestamp.cmd is required. If your computer is too fast for 200 files then increase this number:
Code: Select all
@echo off
echo Version1: findstr
echo %time%
call getTimestamp -f {ums} -r t1
set /a cnt=0
:0
echo %cnt% THE QUICK BROWN FOX JUMPS OVER A LAZY DOG>%cnt%.tmp
echo.>>%cnt%.tmp
for /f "delims=:" %%i in ('findstr /o $ %cnt%.tmp') do set /a len=%%i
del %cnt%.tmp
set /a cnt+=1
if %cnt% LSS 200 goto :0
echo %time%
call getTimestamp -f {ums} -r t2
call getTimestamp -d %t2%-%t1% -f "{ud} days {hh}:{nn}:{ss}.{fff}" -u
echo(
echo --------------------------
echo(
echo Version2: FOR
echo %time%
call getTimestamp -f {ums} -r t1
set /a cnt=0
:1
echo %cnt% THE QUICK BROWN FOX JUMPS OVER A LAZY DOG>%cnt%.tmp
for %%Z in (%cnt%.tmp) do set len=%%~zZ
del %cnt%.tmp
set /a cnt+=1
if %cnt% LSS 200 goto :1
echo %time%
call getTimestamp -f {ums} -r t2
call getTimestamp -d %t2%-%t1% -f "{ud} days {hh}:{nn}:{ss}.{fff}" -u
echo(
echo END
The results:
Code: Select all
Version1: findstr
22:06:24,65
22:06:37,68
0 days 00:00:13.015
--------------------------
Version2: FOR
22:06:38,20
22:06:38,98
0 days 00:00:00.813
END
Maybe you Experts can get a faster version?
Saso