Reputation: 2491
@echo off
set files=InstallSlinger27.bat:Stash.txt
for /F "delims=:" %%i IN ("%files%") DO (
ECHO %%i
if exist %%i (
echo EXIST
) else (
echo DO NOT EXIST
)
)
I expect the batch file to check if the file InstallSlinger27.bat exists and then check if the file Stash.txt exists.
However, the output is
InstallSlinger27.bat
EXIST
It does not do the verification for the second file.
I tried some things, and I did loops in the past that where working. I don't want to do checks for %%i then %%j, because the files list could grow.
Upvotes: 0
Views: 36
Reputation: 80138
@ECHO OFF
SETLOCAL
set files=InstallSlinger27.bat:Stash.txt
FOR %%a IN ("%files::=","%") DO (
IF EXIST %%a (ECHO %%a exists) else (ECHO %%a missing)
)
GOTO :EOF
Although I'd suggest you re-think your choice of separator since :
can occur within a full filename.
Upvotes: 2