1
`@echo off
 chcp 1251>nul
 help | findstr /b [A-Z] > 1.txt
 for /F "tokens=1*" %%1 in ('1.txt') do (help %%1) > %%1.txt
 del 1.txt `

I guess it should be done somehow this way but it doesnt work. This should "take" the name of a command and then use it for "help command"(help if for e,g) and then type it(With echo ofc) in the txt file with name of a command.

  • @aschipfl - Absolutely not true, despite what the MS docs say. Almost any character can be used as FOR variable. More info at http://stackoverflow.com/a/8520993/1012053 – dbenham Oct 11 '15 at 18:10
  • Thanks, @dbenham, just found it out myself, so I'm going to delete the comment... – aschipfl Oct 11 '15 at 18:16
  • possible duplicate of [Generate help files](http://stackoverflow.com/questions/19363893/generate-help-files) – aschipfl Oct 11 '15 at 21:28

2 Answers2

2

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|.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • 1
    that findstr regex doesn't work, `for /F %1 in ('help^|findstr /b [A-Z][A-Z]') do @echo %1` is same as `for /F %1 in ('help') do @echo %1` If you have grep I suggest `help|grep -o -E "(^[A-Z][A-Z]+)"` – Paul Oct 11 '15 at 20:32
  • I'll never understand `findstr`... I changed the regex to "\<[A-Z][A-Z]*\>", so it should return lines with upper-case words only... I don't have `grep`, but I'll definitely check it out -- thanks for the hint, @Paul – aschipfl Oct 11 '15 at 20:40
  • Also I would add an intermediate conversion for the problems of encoding of regional languages `do ( help %%1>"%tmp%\%%1.tmp" cmd /U /C type %tmp%\%%1.tmp>%%1.TXT )` – Paul Oct 11 '15 at 21:38
1

This is repeat of the following that Rob van der Woude coded up..

http://www.robvanderwoude.com/sourcecode.php?src=allhelp_nt

I think there are a couple variations on his site as well.

http://www.robvanderwoude.com/allhelp.php

Thanks.

Leptonator
  • 3,379
  • 2
  • 38
  • 51