Application icon

Test If File Exists

This statement is used to test if an file system item exists at a supplied path. You can test if the item is a file, a folder or either. There are two modes of operation: Test Path and Test Per File.


Test Path

If there is an item at the supplied path and it meets the specified criteria, the result of the test will true. Otherwise the result will be false.

The results of the test can be Set, Anded or Ored to the action test state. The test is not performed if it is unnecessary due to the current value of the test state. For example you are Anding to the test state and it is currently false.

The supplied text may contain any of the escape sequences described in Escape Sequences.

Note that at runtime after processing escape sequences, if the path does not start with / or ~/, the test state will be set to false.

The function is only executed once per set of files while executing stepwise.

When the function succeeds (the test state is true), the following named variables will have been populated. Note that when the function fails, the named variables are cleared.

Test if File Exists Creation Date
The creation date of the file or folder. If the information cannot be extracted, the named variable will be empty.

Test if File Exists Modification Date
The modification date of the file or folder. If the information cannot be extracted, the named variable will be empty.

Test if File Exists File Size
The size of the file or folder. If the information cannot be extracted, the named variable will be empty. Note that the file size returned for folders is typically a meaningless number.

Test if File Exists is Folder
Set to 1 if the item is a folder, otherwise 0.

Test if File Exists is Hidden
Set to 1 if the item is hidden, otherwise 0.

Test if File Exists Attributes
An encoded string of character tags representing file system attributes. The following table describes the character tags and their interpretation.

  Tag  Interpretation
VThe item is a volume.
-The containing volume is read only.
=The containing volume supports case sensitive names. (ie. not case insensitive).
~The containing volume supports preserving case sensitive names. ie. the volume is not case sensitive but preserves names.
>The containing volume is removable.
JThe containing volume is ejectable.
IThe containing volume is internal to the Mac.
LThe containing volume is local. ie. internal or physically connected to the Mac.
SThe item is a symbolic link.
@The item is an alias (produced by the Finder) or a symbolic link.
PThe item is a package. A folder treated by the Finder as a single item.
AThe item is an application.
HThe item is hidden.
EThe item is executable. Note that some file sync utilities and various network based players may set this attribute on audio files and folders.
DThe item is a directory (folder).
FThe item is a file.
RThe item can be read.
WThe item can be written. (ie. not read only).


Test Per File

In this mode, the function tests a path contained in a supplied track variable for all active files. The results of the test (based on the specified criteria) are placed into a supplied results track variable or the file's action per file test state. The results track variables, if used, can be the same as the source if you wish.

The action test state will be true if all files pass the criteria, otherwise false.

The named variables used by the Test Path mode are not modified.

When returning the result to the per file test state, true implies exists while false implies does not exist.

When returning the result to a track variable, the following values can be returned. Note that all non zero results imply existence.


  Result  Meaning
0The item does not exist.
1The item meets the criteria.
-1The item meets the criteria and is hidden.
2This is only possible when the the criteria is Test if the supplied path exists (file or folder). In this case, the item exists and is a folder. 1 is returned for a file.
-2This is only possible when the the criteria is Test if the supplied path exists (file or folder). In this case, the item exists and is a hidden folder. -1 is returned for a hidden file.