lordofdavipers
01-13-2012, 05:00 PM
It's been a long time since I've been here but I still love this place because everyone is so very helpful and I hope, once again, I can get the great assistance as before.
I have not always programmed with batch files but since starting at my new I.T. job I now use them somewhat extensively to automate or make some tasks I do easier. I'm now on my fourth one and have run into a road-block that I hope you guys can help me out with.
Short of the long, we have an internal knowledge base at work of which we search by keyword to find the article(s) we desire. I have written a script, basically for testing my skills, to search the kb by way of the batch file. However, I ran into one stump that I didn't catch originally...the KB uses plus (+) signs in place of spaces. I cannot find for the life of me how to convert spaces to + symbols. I have read mixed reviews that batch files cannot process/parse this and you must use a more powerful programming language such as VB, C++ or something of the like. I'm not quite skilled in those and don't necessarily need this that much.
Although I wrote a nice book above, my question is simply this. Is it true that you cannot perform the above function of converting spaces to + symbols (or any other desired character) or is it possible? If it is, could someone please look at the following code and see if it's possible or where I went wrong (as you'll see my REM statements).
I greatly appreciate any and all assistance!
Code As Follows:
@echo off
TITLE .::KB Quick Search - V. 0.0.1::.
rem CREATE DATE: Wednesday, January 11, 2012, 5:47:17 PM
rem VERSION 0.0.1 (0.0.1 is alpha/beta build. No detailed documentation.)
REM TO DO: CREATE ABILTITY TO CONVERT A SPACE TO A + SYMBOL.
rem THIS FILE IS CREATED AND OWNED BY ANDREW COODY. DO NOT RIP OFF. SEE HELP FILE.
rem http://aaronskb.aaronrents.com/novo/dosearch.asp?words=KEYWORD
rem cls
rem echo.
rem echo.
rem echo.
rem echo. KB Quick Search is designed to load a KB search directly from the command line to the IE/FF search window.
rem echo.
rem echo.
rem echo.
rem pause.
:new
:step0
cls
:step00
rem Destoys value in case values were set.
set "kb="
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.Type "q" to quit.
echo.Temporarily, please input a "+" instead of a space. (VIP+Void)
echo.
set /p "kb=Please enter your KB Quick Search: "
rem NULL VALUE AUDIT
rem if kb ==" " (echo. %kb%"+" && goto :step0end)
rem DOES NOT WORK if kb=="%kb&& %" ren "%kb&& %" "%kb&&+%"
if not defined kb (cls && echo. && echo. && echo. No blank values allowed. Please enter a search term or type "q" to quit. && echo. && echo. && echo. && goto :step00)
if %kb% ==q (goto :quit) ELSE (goto :step0a)
:step0a
:step0end
start http://aaronskb.aaronrents.com/novo/dosearch.asp?words=%kb%
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo. Program will close automatically. Please wait.
ping -n 5 127.0.0.1>nul
:quit
Andrew
I have not always programmed with batch files but since starting at my new I.T. job I now use them somewhat extensively to automate or make some tasks I do easier. I'm now on my fourth one and have run into a road-block that I hope you guys can help me out with.
Short of the long, we have an internal knowledge base at work of which we search by keyword to find the article(s) we desire. I have written a script, basically for testing my skills, to search the kb by way of the batch file. However, I ran into one stump that I didn't catch originally...the KB uses plus (+) signs in place of spaces. I cannot find for the life of me how to convert spaces to + symbols. I have read mixed reviews that batch files cannot process/parse this and you must use a more powerful programming language such as VB, C++ or something of the like. I'm not quite skilled in those and don't necessarily need this that much.
Although I wrote a nice book above, my question is simply this. Is it true that you cannot perform the above function of converting spaces to + symbols (or any other desired character) or is it possible? If it is, could someone please look at the following code and see if it's possible or where I went wrong (as you'll see my REM statements).
I greatly appreciate any and all assistance!
Code As Follows:
@echo off
TITLE .::KB Quick Search - V. 0.0.1::.
rem CREATE DATE: Wednesday, January 11, 2012, 5:47:17 PM
rem VERSION 0.0.1 (0.0.1 is alpha/beta build. No detailed documentation.)
REM TO DO: CREATE ABILTITY TO CONVERT A SPACE TO A + SYMBOL.
rem THIS FILE IS CREATED AND OWNED BY ANDREW COODY. DO NOT RIP OFF. SEE HELP FILE.
rem http://aaronskb.aaronrents.com/novo/dosearch.asp?words=KEYWORD
rem cls
rem echo.
rem echo.
rem echo.
rem echo. KB Quick Search is designed to load a KB search directly from the command line to the IE/FF search window.
rem echo.
rem echo.
rem echo.
rem pause.
:new
:step0
cls
:step00
rem Destoys value in case values were set.
set "kb="
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.Type "q" to quit.
echo.Temporarily, please input a "+" instead of a space. (VIP+Void)
echo.
set /p "kb=Please enter your KB Quick Search: "
rem NULL VALUE AUDIT
rem if kb ==" " (echo. %kb%"+" && goto :step0end)
rem DOES NOT WORK if kb=="%kb&& %" ren "%kb&& %" "%kb&&+%"
if not defined kb (cls && echo. && echo. && echo. No blank values allowed. Please enter a search term or type "q" to quit. && echo. && echo. && echo. && goto :step00)
if %kb% ==q (goto :quit) ELSE (goto :step0a)
:step0a
:step0end
start http://aaronskb.aaronrents.com/novo/dosearch.asp?words=%kb%
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo. Program will close automatically. Please wait.
ping -n 5 127.0.0.1>nul
:quit
Andrew