Get File(s) Information

Declaration

<AMGETFILEINFO FILE="text" RESULTVARIABLE="text" FILEPROPERTY="Text(options)" ISNEWERTHAN="date" />

See Also

Split File | Move File | Create Folder | Delete File | Delete Folder | Rename Folder | Remove Folder | Touch File | Set Attributes | Read from File | Write to File | Synchronize Folders | Concatenate Files

File System - Get Information

Declaration

<AMGETFILEINFO FILE="text" RESULTVARIABLE="text" FILEPROPERTY="Text(options)" ISNEWERTHAN="date" />

See Also

Change Folder | Concatenate Files | Copy | Create Folder | Delete | Get Checksum | Join Files | Move | Read From File | Rename | Split File | Synchronize Folders | Touch | Write To File

Description

Retrieves key information and attributes about one or more files, folders, or volumes and stores the results into an AutoMate variable or dataset. To specify more than one file, use wildcard characters (i.e. * or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (i.e. c:\*.txt|c:\*.bak).

Practical Usage

Commonly used to gather key data about one or more files/folders and perform conditional actions depending on the information.

Parameters

General Properties

Property

Type

Req'd

Default

Markup

Description

Source

Text

Yes

(Empty)

  1. SOURCE="c:\sourcefolder\file.txt"

  2. SOURCE="c:\sourcefolder\*.txt"

  3. SOURCE="c:\source\*.txt|c:\source\*.bak"

  4. SOURCE="c:\foldername"

  5. SOURCE="c:\foldername\subfoldername"

The file or folder in which information should be retrieved from. This can be a fully qualified path and folder/file name (preferred) or a folder/file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to specify files/folders matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with a pipe symbol (c:\*.txt|c:\*.bak).

Calculate file checksum

Yes/No

No

No

VALIDATECHECKSUM="yes"

If enabled, specifies that the checksum of the specified file will be calculated. This parameter is available only if File is the mode to perform this activity on. Enabling this parameter activates the Hash Type parameter.

Hash Type

Text (Options)

No

MD5

HASHTYPE="MD5"

Indicates the algorithm to use during calculation. This parameter is available only if the Calculate file checksum parameter is enabled. The available options are:

  • CRC Cyclical Redundancy Checking. Fastest and least secure.

  • MD5 (default): Message Digest 5. Slower and more secure than CRC.

  • SHA1: Secure Hash Algorithm-1. Slower and more secure than MD5.

  • SHA256: Secure Hash Algorithm-256. Slower and more secure than SHA1.

  • SHA384: Secure Hash Algorithm-384. Slower and more secure than SHA256.

  • SHA512: Secure Hash Algorithm-512. Slowest and most secure.

Calculate directory size

Yes/No

No

No

SIZE=yes

If enabled, the total size of the specified folder will be calculated. This parameter is available only if Folder is the mode to perform this activity on.

Populate variable with result

Text

No

(Empty)

RESULTVARIABLE="theVarName"

 

If enabled, specifies the name of the variable to populate with the chosen folder's/file's information. If File is the mode selected, this variable is populated with either the file's checksum value (if Calculate file checksum parameter is enabled) or its property value. If multiple files/folders are specified, the variable will be populated with file property of each file/folder separated by a semi colon. For example, if the file property selected is Filename, the variable will store information in this manner: fileA.txt;fileB.txt;fileC.txt

File Property

Text

No

Fullname

FILEPROPERTY="Size"

The file property in which to populate the variable with. This parameter is available only if the Calculate file checksum parameter is disabled. The available options are:

  • Fullname - The full path and file name of the file (i.e. C:\Temp\FileName.txt)

  • Parent - The parent folder (i.e. C:\Temp)

  • Filename - The file name and extension, excluding path (i.e. FileName.txt)

  • Extension - The file's extension (i.e. .txt)

  • Size - The size of the file in KB (i.e. 1592)

  • IsReadOnly - Whether the file is Read Only (i.e. True or False)

  • CreationTime - The file's creation date/time (i.e. 3/20/2010 9:20:20 AM)

  • LastAccessTime - The date/time the file was last accessed (i.e. 3/20/2010 9:20:20 AM)

  • LastWriteTime - The date/time the file was last written to (i.e. 3/20/2010 9:20:20 AM)

  • Attribites - The file's attribute (i.e. Archive)

Dataset to populate

Text

No

(Empty)

RESULTDATASET="DatasetName"

If enabled, specifies the name of the dataset to populate with all available  information about one or more files. More details about the dataset that this action creates is entered below under Notes.

General Properties

Property

Type

Req'd

Default

Markup

Description

File/Folder/Volume

Text (Options)

Yes

File

MODE="folder"

Indicates what this activity should be performed on. The available options are:

  • File (default) -  This activity should be performed on file(s). A file is the common storage unit in a computer. All programs and data are contained in a file, and the computer reads and writes files.

  • Folder - This activity should be performed on folder(s). A folder holds one or more files, although a folder can also be empty. Folders provide a method for organizing files similar to a manila file folder containing paper documents in a file cabinet.

  • Volume - This activity should be performed on volume(s). A volume can be a single accessible storage area such as a single hard disc or partition.

Different parameters may be available depending on which option is selected.

File

Text

Yes

(Empty)

  1. FILE="c:\sourcefolder\file.txt"

  2. FILE="c:\sourcefolder\*.txt"

  3. FILE="c:\source\*.txt|c:\source\*.bak"

The file in which information should be retrieved from. This can be a fully qualified path and file name (preferred) or a file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to specify files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with a pipe symbol (c:\*.txt|c:\*.bak). This parameter is available only if File  information is retrieved.

Folder

Text

Text

(Empty)

  1. FOLDER="c:\foldername"

  2. FOLDER="c:\foldername\subfoldername"

The folder in which information should be retrieved from. This can be a fully qualified path and folder name (preferred) or a folder name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to specify folders matching a certain mask. This parameter is available only if Folder information is retrieved.

One Volume/All Volumes

Text

No

(Empty)

VOLUME="SINGLE"

If One Volume is toggled, this activity will get a single volume's specific information and populate a variable with the results. If All Volumes is toggled, this activity will populate a dataset with the information about all volumes retrieved. This parameter is available only if Volume information is retrieved.

Volume

Text

No

A:\

DRIVENAME="C:\"

The volume from which to get data. This parameter is valid only if One Volume parameter is enabled. This parameter is available only if Volume information is retrieved.

Populate variable with result

Text

Yes

(Empty)

RESULTVARIABLE="varName"

The name of the variable to populate with the specified property/information selected. If multiple files/folders are specified, the variable will be populated with file property of each file/folder separated by a semi colon. For example, if the file property selected is Filename, the variable will store information in this manner: fileA.txt;fileB.txt;fileC.txt

File Property

Text

(options)

No

Fullname

FILEPROPERTY="Size"

The file/folder property in which to populate the variable with. This parameter is available only if the mode selected is File or Folder. The available options are:

  • Fullname - The full path and file name of the file (i.e. C:\Temp\FileName.txt)

  • Parent - The parent folder (i.e. C:\Temp)

  • Filename - The file name and extension, excluding path (i.e. FileName.txt)

  • Extension - The file's extension (i.e. .txt)

  • Size - The size of the file in KB (i.e. 1592)

  • IsReadOnly - Whether the file is Read Only (i.e. True or False)

  • CreationTime - The file's creation date/time (i.e. 3/20/2010 9:20:20 AM)

  • LastAccessTime - The date/time the file was last accessed (i.e. 3/20/2010 9:20:20 AM)

  • LastWriteTime - The date/time the file was last written to (i.e. 3/20/2010 9:20:20 AM)

  • Attribites - The file's attribute (i.e. Archive)

Volume Info

 

 

 

 

The type of information with which to populate the variable. This parameter is valid only if One Volume parameter is enabled. The available options are:

  • Volume type (default)

  • Volume label

  • File system

  • Current user's available space

  • Total available space

  • Total capacity

  • Used space

Calculate directory size

Yes/No

No

No

SIZE=yes

If enabled, the total size of the specified folder will be calculated. This parameter is available only if Folder is the mode to perform this activity on.

 

 

 

 

 

 

Dataset to populate

Text

No

(Empty)

RESULTDATASET="DatasetName"

If enabled, specifies the name of the dataset to populate with all available information about one or more files, folders or volumes. More details about the dataset that this activity creates is supplied below under Notes.

File Options Properties

These properties are available only if mode is set to File or Folder. If mode is set to Volume, these properties are ignored.

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/ files matching the mask specified in the Source parameter. If set to NO (default value), subfolders are ignored.

Match Case

Yes/No

No

No

MATCHCASE="yes"

If set to YES, this activity filters out results that match the case of the mask specified in the Source parameter. If set to NO (default), case is ignored.

Exclude Mask

Text

No

(Empty)

  1. EXCLUDE="*.txt"

  2. EXCLUDE="*.txt|*.bak

  3. EXCLUDE="c:\foldename"

Causes this activity to omit folders/files matching the mask(s) specified. Folder/File names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Regular Expression

Yes/No

No

No

RE="yes"

If set to YES, specifies that the data entered in the Exclude Mask field is a regular expression. Set to NO by default.

Attributes Properties

File Filter Properties

These properties are available only if mode is set to File or Folder. If mode is set to Volume, these properties are ignored.

Property

Type

Req'd

Default

Markup

Description

Attributes

Text (Options)

No

(Empty)

ATTRFILTER="+R+A-H" (copy read-only & archive files but not hidden files)

This group of settings causes the action to filter which files should information be retrieved from based on the attribute settings of the source file(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 copy.

Available Options:

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

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Properties

The On Error tab allows you to determine what the task should do if a particular step encounters an error.

More about On Error properties

Notes

Datasets (File/Folder)

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes the file/folder related dataset fields created and populated (assuming the dataset name assigned was theDataset).

Name

Type

Return Value

theDataset.FullName

String

Returns the full path and file name of the file. For Example: C:\Temp\FolderName\FileName.txt

theDataset.Parent

String

Returns the path to the parent folder. For example: If the source is C:\Temp\FolderName\FileName.txt, the parent is C:\Temp\FolderName

theDataset.FileName

String

Returns the file name only. For example: If the source is C:\Temp\FolderName\FileName.txt, the filename is FileName.txt

theDataset.Extension

String

Returns the file extension only. For example: If the source is C:\Temp\FolderName\FileName.txt, the extension is .txt

theDataset.Size

Number

Returns the size of the file in kb.

theDataset.IsReadOnly

True/False

Returns TRUE if the folder/file is read only. Otherwise, returns FALSE.

theDataset.CreationTime

Date

Returns the creation date/time of the folder/file.

theDataset.LastAccessTime

Date

Returns the date and time the folder/file was last accessed.

theDataset.LastWriteTime

Date

Returns the date and time the folder/file was last written to.

theDataset.Attributes

String

Returns the attributes for the file.

theDataset.IsDireactory

True/False

Returns TRUE if the item specified is a folder or directory. Otherwise, returns FALSE.

theDataset.Checksum

Number

Returns the checksum value of the file. This field is populated only if the Calculate file checksum parameter is enabled.

Datasets (Volume)

The table below describes the volume associated dataset fields created and populated (assuming the dataset name assigned was theDataset).

Name

Type

Return Value

theDataset.Drive

Text

Returns the drive from which corresponding data is retrieved.

theDataset.VolumeType

Text

Returns the volume type (i.e. Removable)

theDataset.VolumeLabel

Text

Returns the volume label.

theDataset.FileSystem

Text

Returns the file system (i.e. NTFS)

theDataset.AvailableSpaceforUser

Number

Returns the current user's available space.

theDataset.TotalAvailableSpace

Number

Returns the total available space.

theDataset.TotalSizeofDrive

Number

Returns the total size of the drive.

theDataset.UsedSpace

Number

Returns the used space.

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

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

 

Example 1 - Simple copy file operation.

 

<AMFILECOPY SOURCE="C:\Folder1\*.*" DEST="C:\Folder2" SUBFOLDERS="YES" KEEPFOLDERSTRUCT="NO" OVERWRITE="YES"  RESULTDATASET="FileCopyDataset" />

 

 

Example 2 - Copy file(s) from "C:\Folder1\*.*" to "C:\Folder2\". Include sub folders. Exclude the file mask(s) "*.pri". Overwrite read-only files and files that exist exist in the destination. Create and populate dataset "FileCopyDataset" with details of the file(s) to be copied.

 

<AMFILECOPY SOURCE="C:\Folder1\*.*" DEST="C:\Folder2" SUBFOLDERS="YES" OVERWRITE="YES" ISNEWER="YES" OVERWRITEREADONLY="YES" ONLYIFEXIST="YES" ISNEWERTHAN="%DateSerial(2007,02,24) + TimeSerial(15,40,34)%" ARCHIVETURNOFF="YES" EXCLUDE="*.pri" ATTRFILTER="+a-s" RESULTDATASET="FileCopyDataset" />

 

↑ Top of Page