问题
I have a batch file that I am trying to automate using input redirects from a file. The general idea of the batch file is to copy files over based on a yes or no response.
First, the user is prompted which version they would like to pull the files from. Following that, the user is prompted if they would like to install the different files. If the user chooses yes, the next prompt is delayed due to the file being copied. Here as an example of the output:
Please enter the release version (ex:53)
you would like to pull files from or LATEST:
Get file1 (y/n/a/d) ? y
\\server\share\55\1\file1.exe
1 File(s) copied
\\server\share\55\1\file1.log
1 File(s) copied
\\server\share\55\1\file1.dll
1 File(s) copied
Get file2 (y/n/a/d) ? n
Get file3 (y/n/a/d) ? y
\\server\share\55\3\file3.exe
1 File(s) copied
\\server\share\55\3\file3.log
1 File(s) copied
\\server\share\55\3\file3.dll
1 File(s) copied
...
I use the following file (GetFilesPrompts.txt) for the input redirects:
LATEST
y
n
y
End
But when I run GetFiles.bat < GetFilesPrompts.txt
, it never gets file3. I am pretty new to all of this and I cant think of a good way to debug this. Can anyone point me in the right direction?
EDIT
Here is the command where it is failing:
echo:
echo Choose file(s) [Yes/No/All/Done]...
echo:
for /R "%SRC%" %%F in (%filemask%.*) do call :PICKFILE %%F
echo:
:PICKFILE
if %M%==1 goto EX
set P=%~1
if "%P%" NEQ "%P:exclude\=%" goto EX
if "%P%" NEQ "%P:.32.=%" goto EX
call set P=%%P:%SRC%\=%%
if %M%==2 ( echo Adding %~n1 & goto ADDIT )
set YN=
echo:
call :GN "%P%"
set /P YN=Get %RES% (y/n/a/d) ? &
:set /P YN=Get %~1 (y/n/a/d) ? &
if /I "%YN%" EQU "A" set M=2 & goto ADDIT
if /I "%YN%" EQU "D" set M=1
if /I "%YN%" NEQ "Y" goto EE
来源:https://stackoverflow.com/questions/39104645/input-redirects-not-working-with-batch-file-prompts