If File Exists

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. Use If File Exists to set up conditional actions depending on the state of a file.

Declaration

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

</AMIF>

Examples

<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>

General Tab Parameters

If: Specifies the type of check to be performed.

The available options are:

  • file exists: The If block will be executed if the file exists.

  • file does not exist: The If block will be executed if the file does not exist.

  • file is accessible: The If block will be executed if the file exists and is not locked (in use by another application).

  • file is not accessible: The If block will be executed if the file exists and is locked (in use by another application).

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

File: Specifies the full path and file name to check.

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

Create and populate dataset with result information: 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:

  • Name: the name of the file

  • Size: the file size

  • CreatedOn: the file creation date

  • ModifiedOn: the date the file was last modified

  • AccessedOn: the date the file was last accessed

  • IsFolder: yes/no—name is a folder  

  • IsReadOnly: yes/no—read-only attribute

  • IsArchive: yes/no—archive attribute

  • IsSystem: yes/no—system attribute

  • IsHidden: yes/no—hidden attribute

  • IsCompressed: yes/no—compressed

  • IsAccessible: yes/no—accessible

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Advanced Tab Parameters

Exclude mask: 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.

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

Only if newer than: 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).

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

Only if older than: 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).

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

Click Custom to select from other time options (Last 30 seconds, Last 30 minutes, Last 24 hours, Last 30 Days, Last 12 Months, Last 5 Years, Next 30 Seconds, Next 30 Minutes, Next 24 Hours, Next 30 Days, Next 12 Months, Next 5 Years). A expression appears in the text box (e.g., %DateAdd( "s", -30, CStr( Now() ))%) and the Expression check box is selected. You can also click the Expression Builder icon to build a custom expression.

Attributes Tab Parameters

Attributes: 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 is 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 want to find.

  • 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.

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