The following should work:
@echo off
chcp 1251 > nul
help | findstr /B ".[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" > 1.txt
for /F %%1 in (1.txt) do (help %%1) > %%1.txt
del 1.txt
There were ''
around 1.txt
in the set of for
, so it was interpreted as a command rather than a text file.
tokens=1*
is not necessary as you are using the first token only, so tokens=1
, which is the default, is enough.
However, you can do the same without a temporary file 1.txt
like this:
@echo off
chcp 1251 > nul
for /F %%1 in ('help ^| findstr /B ".[ABCDEFGHIJKLMNOPQRSTUVWXYZ]"') do (help %%1) > %%1.txt
Both scripts above require administrator privileges to run without interruptions, because of the diskpart
command, which requires such privileges even for displaying the help text, stupidly.
The SC
command will halt the scripts due to a y
/n
user prompt whether or not to display help for sub-commands query
and queryex
too. To suppress that, you could try to pipe such a letter into help %%1
, that is, to prepend it with echo y|
or echo n|
.