If file or folder exists

Syntax

iff[-] file
(tab)statements
(tab)...
[else
(tab)statements
(tab)...]

 

Can be single line:

iff[-](file) statements
[else statements]

 

Parameters

file - file to search for. Can be file or folder. Also can be drive. Can be full path or filename.

 

Options:

- not.

 

Remarks

Similar to if.

 

If file exists, execute statements after iff and skip statements after else (if any). Otherwise, skip statements after iff and execute statements after else.

 

QM 2.3.3. Can be used as function. Returns 1 if the file exists, 0 if not.

 

If file is not full path, searches in these places. Works like str.searchpath.

 

See also: dir

 

Examples

iff("c:\m\x.txt") mac- "Copy" ;;if file exists, execute macro "Copy"
iff-("notepad.exe") bee ;;if file  doesn't exist, beep
iff(s) out s ;;if file exists, show path. Path is in variable s
iff-("$My Pictures$") end ;;if special folder doesn't exist, end macro

 Can be used as function
if(iff("file1") and !iff("file2")) out "file1 exist; file2 does not exist."