@ATTRIB

Print Topic  Return to Overview  Previous Topic  Next Topic 

@ATTRIB[filename[,-rhsadecijlopt[,p]]] : If you do not specify any attributes, @ATTRIB returns the attributes of the specified file in the format RHSADECIJNOPT, rather than 0 or 1. If two or more parameters are specified, @ATTRIB returns a 1 if the specified file has the matching attribute(s); otherwise it returns a 0.

 

The basic attributes for FAT volumes are:

 

NNormal (no attributes set)
RRead-only
AArchive
HHidden
SSystem
DDirectory

 

In addition, NTFS volumes allow display of the following extended attributes:

 

EEncrypted
CCompressed
INot content-indexed
JJunction or symbolic link
LJunction or symbolic link
NNormal
OOffline
PSparse file
TTemporary

 

The extended attributes are displayed when @ATTRIB is invoked with a single parameter, but they are suppressed when used for file selection (two or more parameters). To select files based on the extended attributes, see @WATTRIB.

 

Attributes which are not set will be replaced with an underscore. For example, if SECURE.DAT has the read-only, hidden, and archive attributes set, %@ATTRIB[SECURE.DAT] would return RH_A_______. If the file does not exist, @ATTRIB returns an empty string.

 

The attributes (other than N) can be combined (for example %@ATTRIB[MYFILE,HS]). Normally @ATTRIB will only return 1 if all of the attributes match. However, if a final ,p is included (partial match), then @ATTRIB will return 1 if any of the attributes match. For example, %@ATTRIB[MYFILE,HS,p] will return 1 if MYFILE has the hidden, system, or both attributes. Without ,p the function will return 1 only if MYFILE has both attributes.

 

Filename must be in quotes if it contains white space or special characters.

 

See also: Attributes Switches.

 

Examples:

 

echo %@attrib["C:\Program Files\My Program\myfile.exe",rhs,p]

echo Attributes for myfile.exe: %@attrib[myfile.exe]

 

Topic "f_attrib.htm" last edited 4/26/2008. ©2008  JP Software, Inc.
Keywords: @ATTRIB,Attributes,Normal attribute,Read-only attribute,Archive attribute,Hidden attribute,System attribute,Directory attribute,Encrypted attribute,Compressed attribute,Not content-indexed attribute,Junction (reparse point) attribute,Offline attribute,Sparse file attribute,Temporary attribute