@ATTRIB |
|
@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:
| N | Normal (no attributes set) |
| R | Read-only |
| A | Archive |
| H | Hidden |
| S | System |
| D | Directory |
In addition, NTFS volumes allow display of the following extended attributes:
| E | Encrypted |
| C | Compressed |
| I | Not content-indexed |
| J | Junction or symbolic link |
| L | Junction or symbolic link |
| N | Normal |
| O | Offline |
| P | Sparse file |
| T | Temporary |
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]