我正在尝试创建一个批处理文件,按名称搜索特定系列的文件,并创建一个列表来选择要运行/打开的文件。我的问题是我不知道如何将每个结果设置为一个变量。
下面的代码是我目前拥有的:
@echo off
::The code below requests for the user to enter part of the file name
::that he/she is interested in opening. This either provides a file name
::or provides a list of similar file names. I would like to take the list
::and create a numbered list from the user can select by entering the
::associated number.
echo Please enter part of the file name that you would like to search for.
set INPUT=%input%
set /P INPUT=Type input: %=%
dir Template_VBAForm*%INPUT%*.xlsm /b /s
pause
最佳答案
这里有一个简单的示例,或许可以帮助您入门。
@Echo Off
Set/P "INPUT=Please enter your part file name search term: "
Set "resp=Where/R .\ "Template_VBAForm*%INPUT%*.xlsm""
Set "i=0"
For /F "Delims=" %%A In ('%resp%') Do (Set/A "i+=1"
Call Set "[%%i%%]=%%A")
Set [||GoTo EndIt
Set/P "INPUT=Please enter an item number: "
If Defined [%INPUT%] Call Echo %%[%INPUT%]%%
:EndIt
Pause
关于windows - 尝试创建批处理文件以选择要打开的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46854922/