![]() |
![]() |
![]() |
|
![]() | |
![]() |
![]() |
![]() |
![]() |
![]() |
Log In | Not a Member? |
Support
![]() |
![]() |
SYNTAX Exists name1 [name2]… [-a] [-d | -f | -w] [-n] [-q] DESCRIPTION The Exists command confirms the existence of one or more files and directories. The nonexistence of name is not considered an error, so the status remains 0. INPUT None OUTPUT Standard output. Exists writes to standard output the name of items that exist and match the criteria specified by the -d, -f, or -w options. If the contents of name do not exist, or do not match the specifications, no output is returned. STATUS
Exists can return the following status codes. Note that the status remains 0 even if a specified file or directory does not exist.
PARAMETERS name1 [name2]… Specifies one or more files and directories. OPTIONS -a Checks if name is a Finder alias file and returns its name only if it exists and is a Finder alias file. -d Checks if name is a directory and returns its name only if it exists and is a directory. -f Checks if name is a file (as opposed to a directory). Returns its name only if it exists and is a file. Note that if you specify -f, Exists does not return the name of an alias file. -n Does not resolve leaf aliases in any path specified on the command line (name1, name2, and so on). This option causes Exists to simply check if a file or folder of any type exists with the given name (and path, if specified). -q Does not place quotation marks around pathnames that are written to standard output. -w Checks if the user has write-access to the file name. You cannot write to a file if it is open or locked.
Note EXAMPLES The following command line checks to see if Count.c and EditCDev.c exist and, finding that they do, returns their names to standard output:
Exists Count.c EditCDev.c In the following example, Exists checks whether HD:dir already exists as a directory before creating a new folder with the same name. If it does not exist, the script creates it and copies to this new directory all files in the current directory ending in ".c". Otherwise the MPW Shell copies the files to the existing directory.
If Not "`Exists -d HD:dir`"
|