|
If - Compare files |
Declaration
<AMIF ACTIVITY="comparefiles" FILEA="text" FILEB="text" COMPARETYPE="text (options)" HASHTYPE="text (options)" />
Description
Compares two files using the specified criteria and returns TRUE if the values match or FALSE if they don't. 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).
Practical Usage
A conditional statements that can perform different actions during the course of a task depending on the result of a file comparison.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
File A | Text | Yes | (Empty) | FILEA="C:\Folder\FileA.txt" | The path and file name of the file to compare against the one specified in the File B parameter. Click the Folder icon and navigate to the desired file or enter the path and file name manually in the provided field. |
File B | Text | Yes | (Empty) | FILEB="C:\Folder\FileB.txt" | The path and file name of the file to compare against the one specified in the File A parameter. Click the Folder icon and navigate to the desired file or enter the path and file name manually in the provided field. |
Compare type | Text (options) | Yes | Size | COMPARETYPE="CRC" | The
criteria to use when comparing the two files. The available options
are:
|
Checksum algorithm | Text (options) | Yes if Compare type set to CRC/Hash | CRC | HASHTYPE="MD5" | The
algorithm to use when comparing the two files. This parameter
is available only if the Compare
type parameter is set to CRC/Hash.
The available options are:
|
Example
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
Description
Compare file "C:\temp1\log.txt" with file "C:\temp2\log.txt". Compare hash values. Use the MD5 algorithm. If hash values match, delete files "C:\temp2\log.txt."
<AMIF ACTIVITY="comparefiles" FILEA="C:\temp1\log.txt" FILEB="C:\temp2\log.txt" COMPARETYPE="crc" HASHTYPE="md5"><AMFILESYSTEM ACTIVITY="delete" SOURCE="C:\temp2\log.txt" /></AMIF>
<AMFILESYSTEM ACTIVITY="delete" SOURCE="C:\temp2\log.txt" />
<AMIF ACTIVITY="end" />