Get File(s) Information

Retrieves information (i.e. File Name, Extension, Creation time, Modified time) regarding one or more files and stores the results into a variable or dataset. To specify more than one file, use wildcard characters (i.e. * or ?).  Commonly used to gather data about one or more files and perform conditional actions depending on the information.

Declaration

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

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

See Also: Touch File, Copy File, Move File, Delete File, Delete Folder, Rename Folder, Write to File, Join File, Concatenate Files, About Datasets

General Tab

Property

Type

Required

Default

Markup

Description

Source

Text

Yes

(Empty)

a)SOURCE="c:\sourcefolder\file.txt"

b)SOURCE="c:\sourcefolder\*.txt"

c)SOURCE="filename.txt"

The file(s) from which information should be retrieved. 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.

Populate variable with result

Text

No

(Empty)

a)RESULTVARIABLE="theFileName.txt

b)RESULTVARIABLE="fileA.txt;fileB.txt"

If enabled, specifies the name of the variable to populated with the chosen file's information as specified in the File property parameter. If multiple files are specified, the variable will be populated with file property of each file 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, etc.

File Property

Text

No

Fullname

FILEPROPERTY="Size"

The file property with which to populate the variable. This parameter is available only when the Populate variable with result parameter is enabled. 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)

  • Attributes - 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 about datasets

Options Tab

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

Exclude Mask

Text

No

(Empty)

EXCLUDE="*.txt"

Causes this action to omit files matching the mask(s) specified. File names or wildcard masks may be used.

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.

Only if Newer Than

Date

No

(Empty)

ISNEWERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes this action to only include files if the source is newer than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored.

Only if Older Than

Date

No

(Empty)

ISOLDERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes this action to only include files if the source is older than the date/time specified. If this parameter is left blank or not included, the date of the files will be ignored.

Attributes Tab

Property

Type

Required

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 want 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 Tab

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 Tab

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

More on Error Causes

On Error Tab

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

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