If File Exists Action

Declaration

<AMIF ACTION="text [options]" FILE="text" EXCLUDE="text" ISNEWERTHAN="datetime" ISOLDERTHAN="datetime" ATTRFILTER="text [attribute mask]" "RESULTDATASET="text">

See Also

If File Exists Action-Setting Properties, If Folder Exists Action, Else Action, End If Action, Loop Files Action, The BASIC Language All Groups

Description

Causes the steps following this action to execute if the specified file is in the specified state. If not, execution follows the next Else or End If action, whichever comes first. Wildcard characters can be used.

Practical Usage

To set up conditional actions depending on the state of a file.

Parameters

General Tab

If

Text, Optional, Default: exist
MARKUP: ACTION="not_exist"

Specifies the type of check to be performed.

The available options are:

Filename

Text, Required
MARKUP: FILE="c:\foldername\filename.txt"

Specifies the full path and file name to check.

Create and Populate Dataset with Result Information

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Specifies the name of a dataset to be created and populated with the file data for the file that caused the If block to be executed. In addition to the standard dataset fields, the dataset will contain the following:

Advanced Tab

Exclude Mask

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*.txt"

Causes the action not to look for files matching the masks specified. File names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Only if Newer Than

Date, Optional, Default: (none)
MARKUP: ISNEWERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes the action to look only for files newer than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if older than [ISOLDERTHAN] parameter).

Only if Older Than

Date, Optional, Default: (none)
MARKUP: ISOLDERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes the action to look only for files older than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored (unless limited by the Only if newer than [ISNEWERTHAN] parameter).

Attributes Tab

Attributes

Text, Optional, Default: (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (include read-only and archive files, not system or hidden)
ATTRFILTER="-S" (do not include "system" files)

This group of settings causes the action to filter which files to look for based on the attribute settings of the source files.

In visual mode, a group of controls are provided to assist in the selection of this parameter. In markup mode, a single text item must be specified that contains the attributes of the files you wish to look for.

Available Options:

R—Read-only: Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

A—Archive: Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

S—System: Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

H—Hidden: Specifying "+H" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

C—Compression: Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Examples

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMIF FILE="c:\foldername\filename.txt">
<AMMESSAGEBOX>The file exists</AMMESSAGEBOX>
</AMIF>

<AMIF ACTION="accessible" FILE="C:\FolderName\*.*" EXCLUDE="*.doc" ISNEWERTHAN="%DateSerial(2007,02,01) + TimeSerial(00,00,00)%" ATTRFILTER="-s" RESULTDATASET="IfFileDataset">
<AMSPEAK ENGINE="automatic">A file is accessible.</AMSPEAK>
</AMIF>.