From MiniScript Wiki
Jump to navigation Jump to search

In Mini Micro and command-line MiniScript, the file.exists function checks if a file or directory exists at the specified path.


Parameter Name Meaning
filePath an absolute or relative path of the file or directory to be tested.

Return Meaning
1 (true) The file or directory exists.
0 (false) The file or directory does not exist.


Test the existence of various files and directories:

if file.exists("/usr2") then print "/usr2 appears to be mounted!"
if file.exists("/usr2/") then print " is there!"

// Look for a file in the parent directory of the current working directory. 
if not file.exists("../output.txt") then
  file.writeLines "../output.txt", "This file will be created with this string at the top. Woot!"
  file.writeLines "../output.txt", "This file will be overwritten with a BETTER string at the top."
end if