If - Folder Exists

Declaration

<AMIF ACTIVITY="folder_exist" FOLDER="text" MODE="text (options)" SUBFOLDERS="yes/no" EXCLUDE="text" RE="yes/no" ISNEWERTHAN="date serial" ISOLDERTHAN="date serial">

Description:

Determines the existence of a folder and returns TRUE or FALSE depending on the outcome. If the result evaluates to TRUE, the task will execute the block of steps immediately following this step up until an End if step is encountered. If the result evaluates to FALSE, the block will be skipped and execution will proceed directly after the End if step (or if an Else step is encountered, the task will execute that block of steps instead, up until an End if step is encountered). This activity supports wildcard characters (e.g.,* or ?).

Note: All If activities must be followed at some point with an End if step to mark the end of the code block that is to be executed if the expression is true. For ease of use, any If activity added to the Steps pane of the task builder is always followed by an End if activity.

Practical Usage

Generally used to check if a folder exists (or does not exist) and execute conditional actions depending on the result.

Parameters

General

Property

Type

Required

Default

Markup

Description

If

Text (Options)

Yes

Folder exists

  1. ACTION="exist"

  2. ACTION="not_exist"

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

  • Folder exists - The IF block will be executed if the specified folder exists.

  • Folder does not exist - The IF block will be executed if the specified folder does not exist.

Folder

Text

Yes

(Empty)

FOLDER="c:\foldername\"

Specifies path and name of the folder to evaluate. Wildcard characters * or ? are supported. For example, to specify all folders that contain the word 'log', enter "c:\*log*\"

File Options

Property

Type

Required

Default

Markup

Description

Include subfolders

Yes/No

No

No

SUBFOLDERS="yes"

If set to YES, denotes that, if present, subfolders should be searched for folders matching the mask specified in the Folder parameter. If set to NO (default), subfolders are ignored.

Exclude Mask

Text

No

(Empty)

EXCLUDE="*temp*"

Causes this activity to omit folders matching the mask specified. Folder names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|).

Only if newer than

Date

No

(Empty)

ISNEWERTHAN=

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

Causes this activity to evaluate only folders with a creation date newer than the date/time specified. If this parameter is left blank or not included, the folder date will be ignored.

Only if older than

Date

No

(Empty)

ISOLDERTHAN=

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

Causes this activity to evaluate only folders with a creation date older than the date/time specified. If this parameter is left blank or not included, the folder date will be ignored.

File Filter

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 activity to filter which folders to look for based on the attribute settings of the source folder(s). 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 are:

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

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

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

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

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

Description

Error Causes

On Error

Example

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

Description: Determines whether folder C:\Temp exists and displays the results in a message box.

 

<AMIF FOLDER="C:\Temp">

     <AMMESSAGEBOX>Folder exists.</AMMESSAGEBOX>

<AMELSE />

     <AMMESSAGEBOX>Folder does not exist.</AMMESSAGEBOX>

</AMIF>