[Batch] Google Search Script (Text & Images, + History Keeper)

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
Here's a batch script I created to perform a google search, for both text and images, along with keeping a history of recently queued searches for both image and text.

Code:
@echo off && setlocal enabledelayedexpansion
title Google Search
color 0B

:menu
cls
echo    GOOGLE SEARCH
echo   ===============
echo.
echo    1 - Text Search
echo    2 - Image Search
echo    3 - Lookup History
echo    4 - Clear History
echo.
echo    Q - Quit
echo.
choice /c:1234Q>nul

if errorlevel 5 goto :EOF
if errorlevel 4 call :History Clear
if errorlevel 3 call :History Lookup
if errorlevel 2 call :SearchQueue Image
if errorlevel 1 call :SearchQueue Text
goto :EOF

:SearchQueue
set /p s=%1 Search Queue:
set s=!s: =+!
if %1 equ Text (
    start http://www.google.com/search?q=!s!
) else (
    start http://images.google.com/images?q=!s!
)
call :WriteHistory !s!
goto menu

:History
if %1 equ Lookup (
    if not exist "history.txt" (
        echo No search history exists...
        ping 127.0.0.1 /n 2 > nul
    ) else (
        echo.
        echo History:
        echo ---------
        type "history.txt"
        echo.
        pause
    )
) else (
    del /f/q "history.txt" 2>&1 | echo > nul
    echo History cleared^^!
    ping 127.0.0.1 /n 2 > nul
)
goto menu

:WriteHistory
set h=%1
set h=!h:+= !
echo !h! >> "history.txt"

Enjoy :)

Note: If the choice command is unavailable for your Windows OS build version, then... Upgrade to a better Windows OS! lol, or change it to an input variable instead.
 
Back
Top