FileInfo function vs. fileName:fileAttribute syntax

View some of the Frequently Asked Questions to our support staff. Included are some tips and tricks making this forum ideal for users getting started with GoAnywhere MFT. Note: Users can reply to existing topics but only our support staff can add new topics to this forum.
1 post Page 1 of 1


Support Specialist
Posts: 9
Joined: Mon Jul 22, 2019 11:32 am

Post by Support_Hans » Thu Sep 26, 2019 2:28 pm

How do I utilize the FileInfo() function and the ${fileName:fileAttribute} syntax correctly?


There is no real difference between these two methods. In fact, either one may be used to retrieve the attributes of a file. When using ${fileName:fileAttribute}, the fileName parameter can be a constant, a variable containing a single file name, or the current file from a For-Each Loop iterating over a fileList variable.
Using the FileInfo() function will require providing the direct path, which may but is not required to be a variable and may be directly defined. FileInfo() utilizes the ${variableName:FileAttribute} syntax, so it is important to know how this syntax works before using this function.

variableName:FileAttribute syntax
The Local File variable specifies the absolute path and name of a single file or folder. To retrieve the attributes of a complex variable, use the following variable reference syntax: ${variableName:fileAttribute}. The colon separates the variable from the attribute.
Each Local File variable contains the following attributes for a file or folder:
-"name": The name of the file or folder, including the extension if one exists. If the Local Files' path is /orders/company/1234.txt, then the value of this attribute would be 1234.txt.
-"exists": This returns either true or false depending on whether the file or folder exists.
-"extension": The extension of the file if one exists. If the Local File variable is a directory, then the value of this attribute will be an empty string. If the Local File variable is a data file and the file has an extension, the extension will be returned. If the file does not have any extension, an empty string is returned.
-"lastModifiedDate": The last modified date and time of the file or folder in ISO format, yyyy-MM-dd HH:mm:ss.SSS.
-"LastModifiedMillis": The last modification date and time of the file or folder in milliseconds since the Unix timestamp (January 1, 1970).
-"size": The size of the file in bytes as a whole number. It is not recommended to use this attribute on folders as the size can vary per operating system and by the metadata on the folder. The size attribute on a folder does not consider the contents or number of files in the folder.
-"parentFile": The path or folder location containing the file. The path and path separators are dependent on the host operating system.
-"path": The absolute path of the file or folder. The path and path separators are dependent on the host operating system.
-"nameWithoutExtension": The name of the file excluding the extension.

*note*: All attribute names are case sensitive.

FileInfo() function
The FileInfo() function returns information on the Local File specified, such as size, last modified date, file directory, etc. The syntax is as follows: ${FileInfo(filePath):FileAttribute}, where filePath is any string, variable or function that returns a file path, and FileAttribute may be any of the listed attributes above.
${FileInfo("C:\example.txt"):exists} - Returns true or false indicating whether or not the file exists.
${FileInfo("resource:smb://resourceName/file.txt"):size} - Returns the file size of the specified file in a Network Share resource.

*note*: the filePath parameter must be a string. When looping over a fileList variable, the current file variable is still a fileList variable so you must use the String() function to convert from a fileList variable to a string variable. e.g. ${FileInfo(String(currentFile)):name} will retrieve the file name and extension.
1 post Page 1 of 1