| ATTRIB Attrib is an external command
that allows a user to change the properties of a specified file.
Using attrib, the user has the capability of changing the file to
have either Read-only, Archived, Hidden or System attributes. The
file attributes are bits that are turned on (set to 1) or turned off
(set to 0).
If a file has an attribute of -R, it can be both read from or
written to (it is referred to as read/write). If a file has an
attribute of +R, it can be read from, but not written to (for
example, you can use your word processor to look at it but not to
alter it).
Syntex to displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path]
filename] [/S [/D]]
+ :Sets an attribute.
- :Clears an attribute.
R :Read-only file attribute.
A :Archive file attribute.
S :System file attribute.
H :Hidden file attribute.
/S :Processes files in all directories in the specified
path.
/D :Process folders as well.
Multiple attributes can be set/cleared by combining switches
(separated by spaces).
Examples
attrib
Typing attrib by itself will display all files in the current
directory and each of their attributes. If any file is hidden it
will also display those files.
attrib directoryname
To display the attributes of a directory
attrib filename
To display the attributes of a file
attrib +r customer.xls
Add the read-only attribute to the customer.xls file so it cannot be
modified until the read only attribute is taken off. This is helpful
for important system files or any other file that you do not want to
have mistakenly edited or changed.
If this file was located on C:\business\customer.xls and you want to
make it read-only then you would use the following attrib +r
C:\business\customer.xls
attrib +h config.sys
Add the hidden attribute to the config.sys file causing it to be not
be seen by the average user.
attrib -h config.sys
This command will do the opposite of the above command. Instead of
hiding the file it will unhide the file if hidden.
attrib -a resume.txt
Turn off archive status.
attrib *.*
To determine the current attribute settings for all of the files in
the current directory
attrib *.* /s
To determine the current attribute settings for all files &
subdirectories
attrib, *.txt
If a comma is typed directly after the command's name all attributes
will be removed from the targeted files (in this case, all .txt
files in the folder). In most versions, if a target isn't specified,
then all attributes will be removed from the folder currently being
browsed in DOS.
|