我正在创建一个批处理文件,该文件必须告诉所需文件夹包含哪些文件,并且能够提示这些文件名。从那里我想要一个输入字段,你输入文件的名称,在这种情况下,打开文件。
我真的有人能够帮助我,这是我这部分的当前代码
:dan
cls
echo Finding files in danish
echo.
dir C:\Users\Anton\Desktop\Skoe\dansk\ /b > files.txt %fi%
dir C:\Users\Anton\Desktop\Skoe\dansk\ /b %fi%
echo.
echo.
echo.
echo.
set /p sr=Which file do you wish to start?
// this is where i need the code to check if the user entered a file name that is in that // folder, and if it is a valid file, send the user to :filestart where hes file will be //started
pause
:filestart
echo filstart
// here i need the desired file started
答案 0 :(得分:0)
@echo off
cls
echo Finding files in danish
echo.
dir C:\Users\Anton\Desktop\Skoe\dansk\ /b > files.txt %fi%
dir C:\Users\Anton\Desktop\Skoe\dansk\ /b %fi%
echo.
echo.
:readFileName
echo.
echo.
set /p sr=Which file do you wish to start?
IF EXIST dansk\%sr% (
goto filestart
) else (
echo %sr% does not exist.
echo Please try again.
goto readFileName
)
pause
:filestart
echo filestart %sr%
start dansk\%sr%