using my machine : w7 32bit
here are the speeds test result (in seconds) between your old and new scripts:
Code: Select all
(tested to produced four files each in one run and i used stopwatch.txt to collect time-speed)
old script speedtest status: new script speedtest status:
---------------------------- ---------------------------
first test = 15.74 first test = 20.15
second test = 16.82 second test = 18.91
take note of above when i repeat again - the old script slowed down while the new script run faster a second around !?
i dont know about the differences?
here is old script with added time-speeds test script and output to four files in one go:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
echo %time% >stopwatch.txt
set maxLen=80
:top
if !count! equ 5 echo %time% >>stopwatch.txt &goto :EOF
for /F "delims=" %%a in (input.txt) do (
set "file=%%a"
call :procFile len=
set len=000!len!
set name[!len:~-4!;!file!]=1
)
for /F "tokens=2 delims=;]" %%a in ('set name[') do (
set "file=%%a"
echo !file:\==! >>old-output!count!.txt
)
set /a "count+=1"
goto:top
:procFile len=
for /L %%i in (0,1,%maxLen%) do if "!file:~%%i,1!" neq "" (
set len=%%i
if "!file:~%%i,1!" equ "=" (
set /A j=%%i+1
for %%j in (!j!) do set "file=!file:~0,%%i!\!file:~%%j!"
)
)
exit /b
here is new script with added time-speeds test script and output to four files:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
echo %time% >stopwatch.txt
set len=10000
set "line="
:top
if !count! equ 5 echo %time% >>stopwatch.txt &goto :EOF
for /F "tokens=1* delims=]" %%a in ('cmd /D /U /C type input.txt ^| find /N /V ""') do (
if "%%b" neq "" (
set /A len+=1
if "%%b" neq "=" (set "line=!line!%%b") else set "line=!line!\"
) else if !len! neq 10000 (
set name[!len:~-4!;!line!]=1
set len=10000
set "line="
)
)
for /F "tokens=2 delims=;]" %%a in ('set name[') do (
set "file=%%a"
echo !file:\==! >>new-output!count!.txt
)
set /a "count+=1"
goto:top
thats all and thanks for new methods and its worth for learning too.
Bars