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

Related Topics   

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 (that is, * 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, by default, any If activity added to the Task Builder's Steps panel 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

 
PropertyTypeRequiredDefaultMarkupDescription
IfText (Options)YesFolder exists
  • ACTION="exist"
  • 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.
FolderTextYes(Empty)FOLDER="c:\foldername\"Specifies path and name of the folder to evaluate. Wildcard characters (that is, * or ?) are supported. For example, to specify all folders that contain the word 'log', enter "c:\*log*\".

File Options

 
PropertyTypeRequiredDefaultMarkupDescription
Include subfoldersYes/NoNoNoSUBFOLDERS="YES"If selected, denotes that, if present, subfolders should be searched for folders matching the mask specified in the Folder parameter. If disabled (default), subfolders are ignored.
Exclude MaskTextNo(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 thanDateNo(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 thanDateNo(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

 
PropertyTypeRequiredDefaultMarkupDescription
AttributesText (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 files to look for based on the attribute settings of the source file. 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 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

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

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

Copy
<AMIF ACTIVITY="file_exist" FILE="c:\temp" />
<AMSHOWDIALOG MESSAGE="The file exists." />
<AMELSE />
<AMSHOWDIALOG MESSAGE="Folder does not exist" />
<AMIF ACTIVITY="end" />