</head> <body> <h1>IfExist / IfNotExist</h1> <p>Checks for the existence of a file or folder.</p> <p class="warning"><strong>Deprecated:</strong> These commands are not recommended for use in new scripts. Use the <a href="FileExist.htm">FileExist</a> function instead.</p> <pre class="Syntax"> <span class="func">IfExist</span>, FilePattern <span class="func">IfNotExist</span>, FilePattern </pre> <h2 id="Parameters">Parameters</h2> <dl> <dt>FilePattern</dt> <dd><p>The path, filename, or file pattern to check. <em>FilePattern</em> is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified.</p></dd> </dl> <h2 id="Related">Related</h2> <p><a href="FileExist.htm">FileExist()</a>, <a href="Block.htm">Blocks</a>, <a href="Else.htm">Else</a>, <a href="LoopFile.htm">File-loops</a></p> <h2 id="Examples">Examples</h2> <div class="ex" id="ExDrive"> <p><a class="ex_number" href="#ExDrive"></a> Shows a message box if the D drive does exist.</p> <pre>IfExist, D:\ MsgBox, The drive exists.</pre> </div> <div class="ex" id="ExPattern"> <p><a class="ex_number" href="#ExPattern"></a> Shows a message box if at least one text file does exist in a directory.</p> <pre>IfExist, D:\Docs\*.txt MsgBox, At least one .txt file exists.</pre> </div> <div class="ex" id="ExNot"> <p><a class="ex_number" href="#ExNot"></a> Shows a message box if a file does <strong>not</strong> exist.</p> <pre>IfNotExist, C:\Temp\FlagFile.txt MsgBox, The target file does not exist.</pre> </div> </body> </html>