check to see whether a file exists in cmd.exe
if exist {insert file name here} (
rem file exists
) else (
rem file doesn't exist
)
# or on a single line (if only a single action needs to occur):
if exist {insert file name here} {action}
# a quick little example testing for both files and/or directories:
md foo
echo.>bar
for %I in (foo bar xyz) do @(
if exist %I (
if exist %I\nul (
echo -- %I is a directory
) else (
echo -- %I is a file
)
) else (
echo -- %I does not exist
)
)