Type: External (3.0 and later)
ATTRIB [d:][path]filename [/S]
ATTRIB [+ R|-R] [+A|-A] [+ H|-H] [+ S|-S] [d:][path]filename [/S]
Sets or displays the read-only, archive, system, and hidden attributes of
Using the ATTRIB command, you can change a file`s read/write attribute or
the archive attribute. If you use this command to specify a file as
the file can be accessed, but not altered or deleted.
If a file has an attribute of -R, it can be both read from or written to
referred to as read/write). If a file has an attribute of +R, it can be
from, but not written to (for example, you can use your word processor to
at it but not to alter it).
If you try to erase a file after you have set its attribute to read-only
DOS will display the words ACCESS DENIED. Before you can erase the file
must use the ATTRIB command to change the file`s attribute to read/write
The BACKUP, RESTORE, and XCOPY commands can use the archive attribute.
use the +A or -A options to selectively back up using the BACKUP
can also use these options to selectively copy using the XCOPY command.
Wildcard characters (? and *) can be used. However, you CANNOT use a
name instead of a filename to change the attributes of all files in a
With DOS Version 5 and later you can hide data files by applying the +H
attribute. -H removes the hidden attribute. The +S (system) and -S
generally used by programmers to hide and unhide command files used only
After applying the hidden or system attribute to a file, it will not
appear in a
directory listing unless you specifically request it with the /A
the DIRECTORY command.
+R - Use the +R option to make a file read-only. Read-only files may
read but they can`t be changed or deleted.
-R - Use the -R option to change the file protection attribute back
normal (so it can be read, changed, or deleted).
+A - Use the +A option to set the ARCHIVE attribute of a file. When
option is used, this flags the file as available for archiving when using
BACKUP or XCOPY commands.
-A - Use the -A option to turn off the ARCHIVE attribute.
+H - With DOS Versions 4 through 6, use the +H option to set the
attribute of a file so that it will not appear in a directory
-H - Use the -H option to turn off the HIDDEN attribute.
+S - With DOS Versions after Version 4, use the +S option to set the
attribute of a file. When the +S option is used, this flags the file as
command file used only by DOS. The file will not appear in a directory
This attribute is generally reserved for programmers.
-S - Use the -S option to turn off the SYSTEM attribute.
/S - Use the /S switch to set attributes on subdirectories found
The following form of the command sets the read-only attribute for the
attrib +r a:sales87.txt
After you have set the read-only attribute for the file SALES87.TXT, DOS
not allow you to delete or modify it (until the attribute is removed).
To set the archive attribute for the file LETTER3.DOC which is in the
directory on drive B, enter
attrib +a b:\letters\letter3.doc
After the archive bit has been set, commands such as XCOPY can
on them (using the BACKUP or XCOPY /M switch). For more information,
the BACKUP and XCOPY command sections.
To determine the current attribute settings for all of the files in the
The attribute settings for all of the files on the current directory will
displayed. If, for example, you were working in the \LETTERS directory
diskette in drive B, ATTRIB would display something like this:
A R B:\LETTERS\SALES87.DOC
This display indicates that three files were found and that the first two
the archive bit set. The second file is also marked as read-only.
Back to the
Easy DOS Command Index