fileinfo

Returns information about a file.

Syntax

fileinfo(path, attribute, [, optional])

Argument

path
The path of the file (a string).
attribute
The attribute being queried (a string).
[, optional]
An optional parameter (a string).

Example

Templex Expression Result
{ fileinfo("e:/demos/angacc.dat", "modified"), %i } 1189688565
{ fileinfo("e:/demos/angacc.dat", "dirname") } e:/demos
{ fileinfo("e:/demos/angacc.dat", "contains", "0"), %i } 94576
{ fileinfo("e:/demos/angacc.dat", "contains", "[Ee][Rr][Rr][Oo][Rr]"), %i } integer

Comments

This function supports querying several attributes. These include: “created”, “modified”, or “accessed”, which return the time (expressed in seconds since January 1st, 1970) that the file was created or last modified or accessed, respectively. You can also query the file’s size in bytes (via “size”), determine which directory the file resides in (via “dirname”) or what the file’s name is when stripped of directory information (via “filename”). Finally, this function will also count the instances of a regular expression (defined by the optional string parameter) found in the file.

The purpose of this function is to facilitate generating metrics about files, especially solver output files referenced by HyperStudy.