Share this page 

Test if a file existsTag(s): Misc Prog HowTo


Single file
@echo off
if exist c:\temp\2010.pdf (
    echo pdf exists
) else (
    echo pdf doesn't exist
)
Using a wildcard
@echo off
if exist c:\temp\*.pdf (
    echo pdf exists
) else (
    echo pdf doesn't exist
)
Single line
if exist c:\temp\2010.pdf echo file exists

if not exist c:\temp\2011.pdf echo file doesn't exist