2

I'm trying to create a .bat file to open 10 google tabs with a slightly altered search.

So Ideally what the file would do is Prompt for user input for a base search term i.e 1000

Then it would ask the user for a range for example 00-10

Then it would open a new google tab with different searches for each number in the range in this case

1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010

And after it would go back to asking the user to choose a new range if they wish

I'm still new to bat files and this is what I could figure out so far, but I can't figure out how to get the original search term and then replace the last two numbers with the various numbers in the range.

@echo off
Set Browser=Chrome.exe

:main
echo Options;
echo 0 : 0-10
echo 1 : 11-20
echo 2 : 21-30
echo 3 : 31-40
echo 4 : 41-50
echo 5 : 51-60
echo 6 : 61-70
echo 7 : 71-80
echo 8 : 81-90
echo 9 : 91-99

set /p "Range= Enter range to search:"

if "%Range%" equ "0" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "1" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "2" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "3" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "4" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "5" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "6" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "7" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "8" start %Browser% -new-tab "https://www.Google.com"
if "%Range%" equ "9" start %Browser% -new-tab "https://www.Google.com"
  • 2
    Probably off topic but I suggest you write PowerShell script instead of batch file if you're on Windows 7 or newer. It's much easier to understand. – Zalatik Jan 21 at 0:49
2

enter image description here


May you can try this / code:


@echo off && verify ^&.^& 2>nul || cls && setlocal enabledelayedexpansion

set "_options=00-10,11-20,21-30,31-40,41-50,51-60,61-70,71-80,81-90,91-99"

:Menu
echo/ & title <nul & title ..\%~0 & echo/ [0]: 00-10 ^|^| [1]: 11-20
echo/ [2]: 21-30 ^|^| [3]: 31-40 && echo/ [4]: 41-50 ^|^| [5]: 51-60
echo/ [6]: 61-70 ^|^| [7]: 71-80 && echo/ [8]: 81-90 ^|^| [9]: 91-99

echo/ & set/p "_opt=Enter range to search options 0-10:" 
echo/ & for /L %%L in (0 1 10) do for %%# in (!_options!
) do if "%%L" == "!_opt!" set "_range=%%~#" && goto :run 

echo/Input is not valid ^^! & %__APPDIR__%timeout.exe 5
echo/ && set "_opt=" <nul && cls && echo/ && goto :Menu

rem :: Use your _range variable when / where needed, I don't
rem :: understand where it enters the Google link, so sorry..

:run
start "" Chrome.exe -new-tab "https://www.Google.com/"
start "" Chrome.exe -new-tab "https://www.Google.com/ncr"
start "" Chrome.exe -new-tab "http://www.google.com/search?q=%_range%"
start "" Chrome.exe -new-tab "http://www.google.com/ncr/search?q=%_range%"
endlocal && goto :EOF

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.