Create nul and all ascii characters with only batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Create nul and all ascii characters with only batch

#76 Post by einstein1969 » 11 Feb 2014 07:23

carlos wrote:I wrote many variants today, but this is maybe the better for me:

In the macro I copied the if else logic from dbenham:

Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham
::Tested under Win8

set "genchr=if %%# equ 26 ("
set "genchr=%genchr% copy /y nul + nul /a 26.chr /a >nul ) else ("
set "genchr=%genchr% if %%# geq 35 if %%# leq 126 if %%# neq 61 ("
set "genchr=%genchr% cmd /a /d /q /c exit /b %%# &cmd /a /d /q /c set /p"
set "genchr=%genchr% "=%%=exitcodeascii%%" <nul >%%#.chr"
set "genchr=%genchr% )) &if not exist %%#.chr ("
set "genchr=%genchr% type nul >%%#.tmp"
set "genchr=%genchr% &makecab /d compress=off"
set "genchr=%genchr% /d reserveperdatablocksize=26"
set "genchr=%genchr% /d reserveperfoldersize=%%#"
set "genchr=%genchr% %%#.tmp %%#.chr >nul"
set "genchr=%genchr% &type %%#.chr"
set "genchr=%genchr% |((for /l %%_ in (1 1 38) do pause)>nul"
set "genchr=%genchr% &findstr ^^^^ >%%#.tmp)"
set "genchr=%genchr% &copy /y %%#.tmp /a %%#.chr /b >nul"
set "genchr=%genchr% &del %%#.tmp)"

for /l %%# in (0,1,255) do (
if exist %%#.chr del /f /q /a %%#.chr >nul
if exist %%#.tmp del /f /q /a %%#.tmp >nul
)

for /l %%# in (0,1,255) do start "" /b /i cmd /a /d /q /c "%genchr%"

:gen255chk
for /l %%# in (0 1 255) do for %%_ in (
%%#.chr) do if not "1"=="%%~z_" goto :gen255chk

goto :eof



Hi Carlos,

Your version need use less resource.

On my system (win7 32bit) this is the problem:

Code: Select all

...
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Memoria insufficiente per eseguire il comando.
Memoria insufficiente per eseguire il comando.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
...


einstein1969

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#77 Post by carlos » 11 Feb 2014 10:20

einstein1969 wrote:Hi Carlos,

Your version need use less resource.

On my system (win7 32bit) this is the problem:

Code: Select all

...
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Memoria insufficiente per eseguire il comando.
Memoria insufficiente per eseguire il comando.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
Impossibile trovare il file specificato.
...

einstein1969


@einstein1969: :o thanks for report it. I would write a new version (i will look the dbenham method for avoid resources)

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#78 Post by carlos » 11 Feb 2014 19:11

@einstein1969, please you can test this:

replace this:

Code: Select all

for /l %%# in (0,1,255) do start "" /b /i cmd /a /d /q /c "%genchr%"


with:

Code: Select all

setlocal enabledelayedexpansion
set "n=0"
:launch
for /l %%# in (%n%,1,255) do (
start "" /b /i cmd /a /d /q /c "%genchr%" 2>>log.txt
if errorlevel 1 (
echo start errorlevel: !errorlevel!>>log.txt
set "n=%%#"
ping -l 0 -n 1 -w 500 1.0.0.0 >nul
goto :launch
)
)


I want know what errorlevel correspond to each message.
Please, you can post the log.txt ?

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Create nul and all ascii characters with only batch

#79 Post by einstein1969 » 12 Feb 2014 08:21

hi ,

this is the output: (this run in infinite loop, after 3 minute i pressed ctrl-C)

Code: Select all

E:\x264\provini>genallchr_carlos.cmd
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
Impossibile accedere al file. Il file è utilizzato da un altro processo.
.....
Impossibile accedere al file. Il file è utilizzato da un altro processo.
^CTerminare il processo batch (S/N)? s


and the log.txt: (is empty)

Code: Select all

E:\x264\provini>type log.txt

E:\x264\provini>
E:\x264\provini>dir *.chr
 Il volume nell'unità E è ACERDATA
 Numero di serie del volume: D4BE-3448

 Directory di E:\x264\provini

12/02/2014  15:15                 1 0.chr
               1 File              1 byte
               0 Directory  10.823.716.864 byte disponibili

E:\x264\provini>dir *.tmp
 Il volume nell'unità E è ACERDATA
 Numero di serie del volume: D4BE-3448

 Directory di E:\x264\provini

File non trovato


the code:

Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham
::Tested under Win8

set "genchr=if %%# equ 26 ("
set "genchr=%genchr% copy /y nul + nul /a 26.chr /a >nul ) else ("
set "genchr=%genchr% if %%# geq 35 if %%# leq 126 if %%# neq 61 ("
set "genchr=%genchr% cmd /a /d /q /c exit /b %%# &cmd /a /d /q /c set /p"
set "genchr=%genchr% "=%%=exitcodeascii%%" <nul >%%#.chr"
set "genchr=%genchr% )) &if not exist %%#.chr ("
set "genchr=%genchr% type nul >%%#.tmp"
set "genchr=%genchr% &makecab /d compress=off"
set "genchr=%genchr% /d reserveperdatablocksize=26"
set "genchr=%genchr% /d reserveperfoldersize=%%#"
set "genchr=%genchr% %%#.tmp %%#.chr >nul"
set "genchr=%genchr% &type %%#.chr"
set "genchr=%genchr% |((for /l %%_ in (1 1 38) do pause)>nul"
set "genchr=%genchr% &findstr ^^^^ >%%#.tmp)"
set "genchr=%genchr% &copy /y %%#.tmp /a %%#.chr /b >nul"
set "genchr=%genchr% &del %%#.tmp)"

for /l %%# in (0,1,255) do (
if exist %%#.chr del /f /q /a %%#.chr >nul
if exist %%#.tmp del /f /q /a %%#.tmp >nul
)

rem for /l %%# in (0,1,255) do start "" /b /i cmd /a /d /q /c "%genchr%"
setlocal enabledelayedexpansion
set "n=0"
:launch
for /l %%# in (%n%,1,255) do (
start "" /b /i cmd /a /d /q /c "%genchr%" 2>>log.txt
if errorlevel 1 (
echo start errorlevel: !errorlevel!>>log.txt
set "n=%%#"
ping -l 0 -n 1 -w 500 1.0.0.0 >nul
goto :launch
)
)


:gen255chk
for /l %%# in (0 1 255) do for %%_ in (
%%#.chr) do if not "1"=="%%~z_" goto :gen255chk

goto :eof



einstein1969

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#80 Post by carlos » 12 Feb 2014 16:40

@einstein1969. Thanks for the test. please you can test again but removing this:

Code: Select all

2>>log.txt

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Create nul and all ascii characters with only batch

#81 Post by einstein1969 » 12 Feb 2014 19:33

Hi, seem that there is no errorlevel...

Code: Select all

....
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Impossibile eseguire il programma specificato.
Il processo ha tentato di scrivere in una pipe non esistente.
Il processo ha tentato di scrivere in una pipe non esistente.
Impossibile trovare il file specificato.
^CTerminare il processo batch (S/N)? s

E:\x264\provini>type log.txt

E:\x264\provini>


the code:

Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham
::Tested under Win8

set "genchr=if %%# equ 26 ("
set "genchr=%genchr% copy /y nul + nul /a 26.chr /a >nul ) else ("
set "genchr=%genchr% if %%# geq 35 if %%# leq 126 if %%# neq 61 ("
set "genchr=%genchr% cmd /a /d /q /c exit /b %%# &cmd /a /d /q /c set /p"
set "genchr=%genchr% "=%%=exitcodeascii%%" <nul >%%#.chr"
set "genchr=%genchr% )) &if not exist %%#.chr ("
set "genchr=%genchr% type nul >%%#.tmp"
set "genchr=%genchr% &makecab /d compress=off"
set "genchr=%genchr% /d reserveperdatablocksize=26"
set "genchr=%genchr% /d reserveperfoldersize=%%#"
set "genchr=%genchr% %%#.tmp %%#.chr >nul"
set "genchr=%genchr% &type %%#.chr"
set "genchr=%genchr% |((for /l %%_ in (1 1 38) do pause)>nul"
set "genchr=%genchr% &findstr ^^^^ >%%#.tmp)"
set "genchr=%genchr% &copy /y %%#.tmp /a %%#.chr /b >nul"
set "genchr=%genchr% &del %%#.tmp)"

for /l %%# in (0,1,255) do (
if exist %%#.chr del /f /q /a %%#.chr >nul
if exist %%#.tmp del /f /q /a %%#.tmp >nul
)

setlocal enabledelayedexpansion
set "n=0"
:launch
for /l %%# in (%n%,1,255) do (
start "" /b /i cmd /a /d /q /c "%genchr%"
if errorlevel 1 (
echo start errorlevel: !errorlevel!>>log.txt
set "n=%%#"
ping -l 0 -n 1 -w 500 1.0.0.0 >nul
goto :launch
)
)


:gen255chk
for /l %%# in (0 1 255) do for %%_ in (
%%#.chr) do if not "1"=="%%~z_" goto :gen255chk

goto :eof



einstein1969

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#82 Post by carlos » 13 Feb 2014 08:16

@einstein1969, thanks for the information. I write a version that use less resources. I tested it successfully on Windows xp with 64 mb. Also I added your idea using a character map.

Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham, einstein1969
::Tested under Win8, WinXP(64mb)

setlocal disabledelayedexpansion

set "map=paddingpaddingpaddingpaddingpadding"
set "map=%map%#$%%&'()*+,-./0123456789:;<p>?@"
set "map=%map%ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"
set "map=%map%abcdefghijklmnopqrstuvwxyz{|}~"

set "genchr=(type nul >%%#.tmp"
set "genchr=%genchr% & makecab /d compress=off"
set "genchr=%genchr% /d reserveperfoldersize=%%#"
set "genchr=%genchr% /d reserveperdatablocksize=26"
set "genchr=%genchr% %%#.tmp %%#.chr 1>nul"
set "genchr=%genchr% & type %%#.chr"
set "genchr=%genchr% |((for /l %%_ in (1 1 38) do pause) 1>nul"
set "genchr=%genchr% & findstr ^^^^ 1>%%#.tmp)"
set "genchr=%genchr% & copy /y %%#.tmp /a %%#.chr /b 1>nul"
set "genchr=%genchr% & del %%#.tmp)"

if exist *.chr del /a /f /q *.chr

start /i /wait /b cmd /a /q /d /c "for /l %%# in (127 1 169) do %genchr%"
start /i /wait /b cmd /a /q /d /c "for /l %%# in (170 1 211) do %genchr%"
start /i /wait /b cmd /a /q /d /c "for /l %%# in (212 1 255) do %genchr%"

for /l %%# in (0 1 34) do %genchr%
cmd /a /v:on /q /d /c "for /l %%# in (35 1 126) do set /p "=!map:~%%#,1!" 0<nul 1>%%#.chr"

:gen255wait
ping -l 0 -n 1 -w 100 1.0.0.0 >nul
for %%# in (169.chr 211.chr 255.chr) do (
if not exist %%# goto :gen255wait
if not "1"=="%%~z#" goto :gen255wait
)

for %%# in (61) do %genchr%
copy /y nul + nul /a 26.chr /a 1>nul

goto :eof

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Create nul and all ascii characters with only batch

#83 Post by dbenham » 13 Feb 2014 09:42

@Carlos - I don't understand why you opted for a fixed number of processes. It really should be tied to the number of available processors (cores). And having each process work on a contiguous range of characters yields uneven distribution of work because of drastic differences between MAKECAB and SET/P. Also, once the work is equally distributed, there is no need for a PING wait while polling for completion because the poll will be so short lived. The poll will not be entered until at least one process has completed, and all processes will finish at nearly the same time because they are doing nearly equal work.

I think my last posted code is a better option. Here is a variation of my last code that uses the character map. In my hands it is only 7% to 10% faster than my version without the character map.

Code: Select all

@echo off
setlocal

:genAllChr
::This code creates 256 1 byte files, one for each possible byte value.
::This is encoded in a macro way to be called asynchronously with start cmd /c
::Teamwork of carlos, penpen, aGerman, dbenham, einstein1969
::Tested under Win7 and XP
set ^"genchr=(^
for /l %%N in (%%A !cnt! 255) do (^
  if %%N equ 26 (^
    copy /y nul + nul /a 26.chr /a ^>nul^
  ) else (if %%N geq 35 if %%N leq 126 if %%N neq 61 (^
    ^<nul set /p "=!ascii:~%%N,1!" ^>%%N.chr^
  ))^&^
  if not exist %%N.chr (^
    makecab /d compress=off /d reserveperdatablocksize=26 /d reserveperfoldersize=%%N %%A.tmp %%N.chr ^>nul^&^
    type %%N.chr ^| ((for /l %%n in (1 1 38) do pause)^>nul^&findstr "^^" ^>%%N.temp)^&^
    ^>nul copy /y %%N.temp /a %%N.chr /b^&^
    del %%N.temp^
  )^
))^&^
del %%A.tmp^"
del /f /q /a *.chr >nul 2>&1
set "ascii=                                   #$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
set /a cnt=number_of_processors
if %cnt% lss 1 set cnt=1
if %cnt% gtr 256 set cnt=256
set /a "end=cnt-1"
for /l %%A in (0 1 %end%) do (
  type nul >%%A.tmp
  if %%A equ %end% (
    cmd /q /v:on /c "%genchr%"
  ) else (
    start "" /b cmd /q /v:on /c "%genchr%"
  )
)
:genAllChr.check
for /l %%N in (0 1 %end%) do if exist %%N.tmp goto :genAllChr.check
exit /b

I chose to set the number of processes to match the number of available processors. You can squeeze out perhaps a wee bit more performance by deploying one or two processes more than available processors. Any more and you are wasting resources without increasing throughput.


Dave Benham

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#84 Post by carlos » 13 Feb 2014 12:37

dbenham wrote:@Carlos - I don't understand why you opted for a fixed number of processes. It really should be tied to the number of available processors (cores).


@dbenham: In my last code I choose a fixed number of process, in this case only 4 process (including the main process), because in my tests there are not performance difference impact in milliseconds between use 4 process, 8 or 256 process. Also, if you have only 1 processor, in your code you will use 1 process, that will be more slow tan use 4 process. I choose use 4 process because works fine for a 1 processor, 4 processor (in my machine I have 4 processors) and the code takes round 4 seconds. That for me is faster and I not need gain 2 or 3 seconds launching more process. Using this fixed number of process the code will runs equals in all machines, and also will be speedy in machines with only 1 processor. Also, keeping fixed the number of process allow check for the last file created of the synchronus block (launched in async way), in my code 169.chr 211.chr 255.chr. the ping is added for reduce the cpu usage. I programming it in that way, because the focus was use less resources. Also, your code is a great work.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#85 Post by carlos » 13 Feb 2014 14:31

the same code reencoded for use less line width:

Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham, einstein1969
::Tested under Win8, WinXP(64mb)

setlocal disabledelayedexpansion

set "map=paddingpaddingpaddingpaddingpadding"
set "map=%map%#$%%&'()*+,-./0123456789:;<p>?@"
set "map=%map%ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"
set "map=%map%abcdefghijklmnopqrstuvwxyz{|}~"

set "gchr=(type nul >%%#.tmp"
set "gchr=%gchr% & makecab /d compress=off"
set "gchr=%gchr% /d reserveperfoldersize=%%#"
set "gchr=%gchr% /d reserveperdatablocksize=26"
set "gchr=%gchr% %%#.tmp %%#.chr 1>nul"
set "gchr=%gchr% & type %%#.chr"
set "gchr=%gchr% |((for /l %%_ in (1 1 38) do pause) 1>nul"
set "gchr=%gchr% & findstr ^^^^ 1>%%#.tmp)"
set "gchr=%gchr% & copy /y %%#.tmp /a %%#.chr /b 1>nul"
set "gchr=%gchr% & del %%#.tmp)"
set "genmap=for /l %%# in (35 1 126) do"
set "genmap=%genmap% set /p "=!map:~%%#,1!" 0<nul 1>%%#.chr"

if exist *.chr del /a /f /q *.chr

start /i /w /b cmd /a /q /d /c "for /l %%# in (127 1 169) do %gchr%"
start /i /w /b cmd /a /q /d /c "for /l %%# in (170 1 211) do %gchr%"
start /i /w /b cmd /a /q /d /c "for /l %%# in (212 1 255) do %gchr%"

for /l %%# in (0 1 34) do %gchr%
cmd /a /v:on /q /d /c "%genmap%"

:gen255w
ping -l 0 -n 1 -w 100 1.0.0.0 >nul
for %%# in (169.chr 211.chr 255.chr) do (
if not exist %%# goto :gen255w
if not "1"=="%%~z#" goto :gen255w
)

for %%# in (61) do %gchr%
copy /y nul + nul /a 26.chr /a 1>nul

goto :eof


foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Create nul and all ascii characters with only batch

#86 Post by foxidrive » 13 Feb 2014 19:10

carlos wrote:machines with only 1 processor.


It would seem that even dual core CPUs have been around for 14 years.

http://en.wikipedia.org/wiki/Multi-core_processor

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#87 Post by carlos » 14 Feb 2014 04:30

foxidrive wrote:
carlos wrote:machines with only 1 processor.


It would seem that even dual core CPUs have been around for 14 years.

http://en.wikipedia.org/wiki/Multi-core_processor


foxidrive: I'm referring to NUMBER_OF_PROCESSORS variable.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#88 Post by carlos » 14 Feb 2014 04:42

I did minor changes to the code:

-enable extensions
-uses new_thread variable
-uses ???.chr instead of *.chr
-remove spaces from map variable, actually this variable not have any space, but i remember that some old forums add a space before the @ character. this is a preventive fix.


Code: Select all

@echo off

:gen255
::generates 0-255 .chr files that have 1 byte
::Teamwork of carlos, penpen, aGerman, dbenham, einstein1969
::Tested under Win8, WinXP(64mb)
setlocal enableextensions disabledelayedexpansion
set "map=paddingpaddingpaddingpaddingpadding"
set "map=%map%#$%%&'()*+,-./0123456789:;<p>?@"
set "map=%map%ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"
set "map=%map%abcdefghijklmnopqrstuvwxyz{|}~"
set "map=%map: =%"
set "gchr=(type nul >%%#.tmp"
set "gchr=%gchr% & makecab /d compress=off"
set "gchr=%gchr% /d reserveperfoldersize=%%#"
set "gchr=%gchr% /d reserveperdatablocksize=26"
set "gchr=%gchr% %%#.tmp %%#.chr 1>nul"
set "gchr=%gchr% & type %%#.chr"
set "gchr=%gchr% |((for /l %%_ in (1 1 38) do pause) 1>nul"
set "gchr=%gchr% & findstr ^^^^ 1>%%#.tmp)"
set "gchr=%gchr% & copy /y %%#.tmp /a %%#.chr /b 1>nul"
set "gchr=%gchr% & del %%#.tmp)"
set "gmap=for /l %%# in (35 1 126) do"
set "gmap=%gmap% set /p "=!map:~%%#,1!" 0<nul 1>%%#.chr"
set "new_thread=start /i /w /b cmd /a /q /d /c"
if exist ???.chr del /a /f /q ???.chr
%new_thread% "for /l %%# in (127 1 169) do %gchr%"
%new_thread% "for /l %%# in (170 1 211) do %gchr%"
%new_thread% "for /l %%# in (212 1 255) do %gchr%"
for /l %%# in (0 1 34) do %gchr%
cmd /a /v:on /q /d /c "%gmap%"
:gen255w
ping -l 0 -n 1 -w 100 1.0.0.0 >nul
for %%# in (169.chr 211.chr 255.chr) do (
if not exist %%# goto :gen255w
if not "1"=="%%~z#" goto :gen255w)
for %%# in (61) do %gchr%
copy /y nul + nul /a 26.chr /a 1>nul
goto :eof


foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Create nul and all ascii characters with only batch

#89 Post by foxidrive » 14 Feb 2014 06:34

carlos wrote:
foxidrive wrote:
carlos wrote:machines with only 1 processor.


It would seem that even dual core CPUs have been around for 14 years.

http://en.wikipedia.org/wiki/Multi-core_processor


foxidrive: I'm referring to NUMBER_OF_PROCESSORS variable.


I don't understand. A dual core will return 2 right?

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Create nul and all ascii characters with only batch

#90 Post by dbenham » 14 Feb 2014 07:19

foxidrive wrote:I don't understand. A dual core will return 2 right?

Yes - %NUMBER-OF-PROCESSORS% returns 4 for my machine that has a single quad core CPU


Dave Benham

Post Reply