@echo off rem AudManSearch.bat Rev 1.1 2016.08.06 rem (eliminated temp file, added rotating selection and New Search), by Dick Neubert. rem This is a batch file for Windows to search the Audacity manual for a given word or phrase. rem It returns a list of the subjects (files) in which the phrase occurs. User can select them rem individually for display in the default html viewer (usually a browser). I haven't figured out rem how to open multiple files simultaneously in browser tabs but Mozilla, Chrome and IE, at least, rem will add tabs if the user selects additional files for display. However, if browser is not open rem already, control won't return to this script until you close the browser, so you won't be able to rem display more files unless you open another instance of this script. rem Regular Expression and Boolean searches are not supported by this script, but R.E. could be. rem I think GREP is a better program for that than FINDSTR, but I used FINDSTR because it comes rem with Windows whereas GREP would have to be downloaded. I intended to impliment multiple rem keyword search (AND rule), but couldn't get past getting nested 'for's to work. Happens on XP, rem Vista and Windows 7, so it's probably some cmd quirk I don't know about yet. I had a similar rem problem below, hence the "goto :rotate". Nested 'for' worked if the break did an exit, but not rem if it did a "goto :finis", so "new search" wasn't available after a match. I'm still working rem on the multiple keyword searches. rem This file may be saved on the Desktop, or saved elsewhere and a shortcut sent to the Desktop. rem Double-click on the icon to run the script, and enter the search phrase when prompted. rem If you just hit 'Enter' in response to the prompt, the script will just introduce itself. rem *IMPORTANT* rem Change the text after '=' in the following 'set' command to the pathname of your help folder. The rem simplest way to do this is to open the help folder (should be in the same folder as Audacity.exe) rem then copy the address bar as text, then paste it here in place of rem everything between '=' and the closing quote: set "AudacityHelp=C:\Program Files (x86)\Audacity 2-1-2\help" rem Note: (above, Windows only) Placing the quotes thus avoids including them in the string assignment. setlocal enableExtensions setlocal enableDelayedExpansion cd %AudacityHelp%\manual\man if not errorlevel 1 goto :okman echo. echo Invalid path for help folder. echo %~nx0 must be edited to insert the correct pathname. echo Instructions for this are given in the file (see echo "*IMPORTANT*"). echo. echo Note: If you're using Windows XP or later, you can echo right-click this file or icon and select 'Edit', or echo drag the %~nx0 file to Notepad. echo. pause Press any key to close window. exit :okman rem prompt user for search string: set search= set /p search= Search for (Word or phrase; Don't use quotes.): if defined search goto :search rem Empty line, show instructions: echo. echo This batch script searches your Audacity manual for a given word or phrase. echo It will not do "regular expression" nor Boolean searches, and avoids echo interpreting the search string as a command to do so. echo. echo A list of files containing the search string will be displayed. You can then echo either go to those subjects in Audacity Help or select them hence for display echo on your default HTML viewer (usually a browser). You can open more than one echo file for display and the browser should open a tab for each one. There's a echo snag here that if your browser is not already open, control may not return to echo this script until you close the browser, therefore the script can't open more echo tabs unless you launch a new instance of this script. After that, it works. echo. echo Once you're in the Match List, you can just hit Enter to go to the next match. echo The list repeats indefinitely until you hit Q, after which you can start a new echo search. Search takes words or phrases, no quotation marks please... echo Rev 1.1 2016.08.06 by DickN. goto :finis :search set files= for /F %%f in ('findstr /I /M /C:"%search%" *.html') do set files=!files! %%f if defined files goto :show echo. echo No matches found. goto :finis :show @echo. @echo Matches: @echo. rem Display file list: for %%f in (%files%) do @echo %%f rem Let user pick one at a time for display (I haven't figured out how to open a set in tabs): set repl=q :rotate @echo. for %%f in (%files%) do ((call :select %%f) & (if /i !repl!==q goto :finis)) goto :rotate rem subroutine to display file contents via default browser :select set repl=N @set /p repl= Display file %1 (Y/[N]/Quit)? rem Keep only the 1st character of reply for tests: set repl=%repl:~0,1% rem Issuing filename.html as a command opens it in the default viewer: if /i %repl%==y call "%~1" rem return from subroutine goto :eof :finis rem See if user wants a new search: set search= @echo. set /p search= Type new search string, or just hit Enter to close window: if defined search goto :search