I want to check if a file exists in a path and then if it exists do a loop. e.g.
IF EXIST "C:\FILE" THEN
LOOP CONDITION
END IF
but in .cmd programming. How would it look like?
I want to check if a file exists in a path and then if it exists do a loop. e.g.
IF EXIST "C:\FILE" THEN
LOOP CONDITION
END IF
but in .cmd programming. How would it look like?
The syntax is like this:
IF EXIST filename. (
FOR %%A IN (1 2 3) DO GOTO=%%A
:1
ECHO 1
GOTO End
:2
ECHO 2
GOTO End
:3
ECHO 3
:End
) ELSE (
echo filename. missing.
)
Take a look at this
I assume that you are using Visual Basic (at least the syntax of IF statement is showing it), if yes, then use FileInfo object like Dim fi As New FileInfo("C:\File.txt") IF fi.Exists() THEN ' Do your loop here END IF