|
File System - Get file checksum |
Declaration
<AMFILESYSTEM ACTIVITY="get_checksum" FILE="text" RESULTVARIABLE="text" HASHTYPE="text (options)" />
Description
Generates a hash (checksum) value for a file and places it into an existing variable. While CRC (Cyclical Redundancy Checking) is the default algorithm, this activity also supports MD5 (Message Digest 5) and several SHA (Secure Hash Algorithm) variants. Available algorithms are placed in order from quickest but least efficient to slowest but most efficient.
Practical Usage
Commonly used to validate the integrity of data by calculating a checksum using the selected algorithm. The result is placed in a variable, which can be stored for later validation of the file or compared with an earlier checksum to verify the file's integrity.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
File | Text | Yes | (Empty) | FILE="c:\folder\file.txt" | The path and file name of the file to retrieve checksum information from. This can be a fully qualified path and file name (preferred) or a single file (requires use of the File System - Change folder activity). Wildcard characters (for example, * or ?) may be used to specify all files matching a certain mask. Multiple files and/or file masks can be specified by separating each entry with a pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details. |
Checksum algorithm | Text (options) | No | CRC |
|
The
algorithm to use for calculation. Available algorithms are placed
in order from quickest but least efficient to slowest but most
efficient. The available options are:
|
Populate variable with the checksum | Text | No | (Empty) | RESULTVARIABLE="VarName" | The name of an existing variable in which to populate with the checksum value. The variable must be created in a previous step using the Variable - Create activity. |
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
This sample task calculates the checksum of a file and then stores the results in a variable.
<AMVARIABLE NAME="theChecksum" />
<AMFILESYSTEM ACTIVITY="get_checksum" FILE="C:\Temp\extract.pdf" RESULTVARIABLE="theChecksum" HASHTYPE="md5" />
<AMSHOWDIALOG WINDOWTITLE="Checksum">MD5 Checksum Value = %theChecksum%</AMSHOWDIALOG>