IfExist / IfNotExist

Checks for the existence of a file or folder.

Deprecated: These commands are not recommended for use in new scripts. Use the FileExist function instead.

IfExist, FilePattern
IfNotExist, FilePattern

Parameters

FilePattern

The path, filename, or file pattern to check. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

FileExist(), Blocks, Else, File-loops

Examples

Shows a message box if the D drive does exist.

IfExist, D:\
    MsgBox, The drive exists.

Shows a message box if at least one text file does exist in a directory.

IfExist, D:\Docs\*.txt
    MsgBox, At least one .txt file exists.

Shows a message box if a file does not exist.

IfNotExist, C:\Temp\FlagFile.txt
    MsgBox, The target file does not exist.