If File Exists Action Icon

If File Exists

Declaration

<AMIF ACTION="text(options)" FILE="text" ISNEWERTHAN="date" ATTRFILTER="text" RESULTDATASET="text">

See Also

Else | End If | End Select/Case | Goto | If | If Compare Files | If File Exists | If Folder Exists | If Last Step | If Pixel Exists | If Process Running | If Text Contains | If Windows Exists | Label | Select/Case

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 (i.e. * or ?) are supported.

Practical Usage

Used to execute conditional actions based on the state of a file.

Parameters

General Properties

Property
Type
Required
Default
Markup
Description

If

Text

Yes

Exists

ACTION="not_exist"

Specifies the type of evaluation to be performed. The available options are:

  • File exists: Results to TRUE if the file exists.

  • File does not exist: Results to TRUE if the file does not exist.

  • File is accessible: Results to TRUE if the file exists and is not in a locked state (i.e. in use by another application).

  • File is not accessible: Results to TRUE if the file exists and in a locked state.

File

Text

Yes

(Empty)

a)FILE="c:\folder2\fileA.txt"

b)FILE="c:\folder2\*.txt"

Indicates the full path and file name of the file in which to evaluate. Wildcard characters (i.e. * or ?) are supported.

Create and Populate Dataset with Result Information

Text

No

(Empty)

RESULTDATASET="theData"

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. The table below (under Notes) describes the set of fields that the dataset creates exclusive to this action.

Create and populate dataset with ACL info

Text

Yes

(Empty)

RESULTDATASET="myDataset"

Specifies the name of a dataset in which to create and populate the ACL information with. This activity creates and populates a dataset containing a specific set of fields. More details about the various fields (columns) this dataset creates can be found below under Datasets.

 

Advanced Properties

Property
Type
Required
Default
Markup
Description

Exclude Mask

Text

No

(Empty)

EXCLUDE="*.txt"

Causes this action to omit 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 (|). Example: *.txt|*.bak

Only if Newer Than

Date

No

(Empty)

ISNEWERTHAN=

"%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes this action to evaluate only files newer than the date/time specified. If this parameter is left blank or not included, the file date will be ignored.

Only if Older Than

Date

No

(Empty)

ISOLDERTHAN=

"%DateSerial(2007,02,01) + TimeSerial(00,00,00)%"

Causes this action to evaluate only files older than the date/time specified. If this parameter is left blank or not included, the file date will be ignored.

 

Attributes Properties

Property

Type

Required

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H" (compress read-only & archive files but not hidden 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 "+R" 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.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Properties

The On Error tab allows you to determine what the task should do if a particular step encounters an error.

More about On Error properties

Notes

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes these fields (assuming the dataset name assigned was theDataset).

Name

Data Type

Return Value

theDataset.Name

Text

The name of the file.

theDataset.Size

Number

The size of the file.

theDataset.CreatedOn

Date

The file creation date.

theDataset.ModifiedOn

Date

The date the file was last modified.

theDataset.AccessedOn

Date

The date the file was last accessed.

theDataset.IsFolder

Yes/No

Whether the file is a folder.

theDataset.IsReadOnly

Yes/No

Whether the file's attribute is Read Only.

theDataset.IsArchive

Yes/No

Whether the file's attribute is Archive.

theDataset.IsSystem

Yes/No

Whether the file's attribute is System.

theDataset.Hidden

Yes/No

Whether the file's attribute is Hidden.

theDataset.IsCompressed

Yes/No

Whether the file is compressed.

theDataset.IsAccessible

Yes/No

Whether the file is accessible.

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (Example: %myVariable% or %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert expression/variable button or pressing F2.

More on variables
More on expressions
More on the Expression Builder

Example

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

 

Description: The task checks if "c:\foldername\filename.txt" exists. If so, a Message Box activity displays the message "The file exists". The task then checks if the same file is currently accessible. If so, a Speak action speaks the message "The file is accesible". To make sure this task works properly, point the If File Exists steps to a valid file name.

 

<AMIF FILE="c:\foldername\filename.txt">

     <AMSHOWDIALOG MESSAGE="The file exists." />

</AMIF>

<AMIF ACTION="accessible" FILE="c:\foldername\filename.txt" ATTRFILTER="-s">

     <AMSPEAK>The file is accessible.</AMSPEAK>

</AMIF>

 

↑ [Top of Page]