我正在尝试创建一个 .bat 文件来打开 10 个 Google 标签并稍微改变搜索功能。
因此,理想情况下,该文件将提示用户输入基本搜索词,即 1000
然后它会要求用户输入一个范围,例如 00-10
然后它会打开一个新的谷歌标签,在这个例子中,对范围内的每个数字进行不同的搜索
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
然后它会返回询问用户是否愿意选择新的范围
我对 bat 文件还不熟悉,这是我目前能弄清楚的,但我不知道如何获取原始搜索词,然后用范围内的各个数字替换最后两个数字。
@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"
答案1
@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