@FILE

Top  Previous  Next

Syntax:

 

@FILE(<file description>, <flags>)

 

Description:

 

This function returns information about <file description> (which may be a URL [VDS6]) if it exists. It returns a null string if the file does not exist, therefore this function may also be used to test for a file's existence.

The <flags> may be used to specify the information that is returned. The flags may also include file attributes, if it is required to test for the presence of a folder or limit the search to certain file types, such as system files. By default, the function will return information about any file, including hidden and system files.

The following flags specify the information that is returned:

F

returns the filename (this is returned by default)

L

returns the name of the file linked to by a shortcut (.LNK) file (this is no guarantee that the file exists)

Z

returns the file size, in bytes

T

returns the file timestamp, in a format that can be passed to the @DATETIME function

Y

returns a string of flags representing the file attributes, these are:

R

read-only

H

hidden

S

system

D

directory

A

archive

N

normal

T

temporary

C

compressed

O

offline

Where more than one information flag is specified, the items of information are returned separated using the current field separator character, in a form suitable for use by the PARSE command. Note that unlike some VDS functions, the information is returned in a fixed order, as shown in the above table (top to bottom) and not in the order the flags are given.

To exclude certain types of files from the test, the attribute flags R, H, S, A and N may be used to restrict the match to files having those attributes. Files that have both hidden and system attributes, are only included if both H and S are in the attribute string. The D flag should be included if you wish to test for the presence of a directory. If you wish hidden and system directories to be included, specify the flags DHS.

[VDS6] If <file description> is a URL, then the file size and time stamp information is that returned by the web server. Some simple web servers may not return this information. Some web servers may be set up to return an information page (custom 404 error page) if the file being requested does not exist. The @FILE function is unable to distinguish between this and the information that would be returned if the file existed, so in this case the file will appear to exist and the size and time stamp will be those of the information page.

OK:

 

Unchanged

 

Examples:

 

parse "%F;%S;%D",@file(c:.bat,FTZ)

if @file(%F,D)

  info Directory %F does not exist

end

 

See also: