ATTRIB commandoer

More
11 months 3 weeks ago #49 by JudgeFredd
ATTRIB commandoer was created by JudgeFredd
ATTRIB
Type: External (3.0 and later)

Syntax:

ATTRIB [d:][path]filename [/S]
ATTRIB [+ R|-R] [+A|-A] [+ H|-H] [+ S|-S] [d:][path]filename [/S]

Purpose:
Sets or displays the read-only, archive, system, and hidden attributes of a file or directory.

DiscussionUsing the ATTRIB command, you can change a file`s read/write attribute or set the archive attribute. If you use this command to specify a file as read-only, 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 (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).



NOTE:
If you try to erase a file after you have set its attribute to read-only (+R), DOS will display the words ACCESS DENIED. Before you can erase the file you must use the ATTRIB command to change the file`s attribute to read/write (-R).

The BACKUP, RESTORE, and XCOPY commands can use the archive attribute. You can use the +A or -A options to selectively back up using the BACKUP command. You can also use these options to selectively copy using the XCOPY command.

Wildcard characters (? and *) can be used. However, you CANNOT use a directory name instead of a filename to change the attributes of all files in a directory.

With DOS Version 5 and later you can hide data files by applying the +H (hidden) attribute. -H removes the hidden attribute. The +S (system) and -S options are generally used by programmers to hide and unhide command files used only by DOS. 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 parameter of the DIRECTORY command.

Options+R - Use the +R option to make a file read-only. Read-only files may be read but they can`t be changed or deleted.

-R - Use the -R option to change the file protection attribute back to normal (so it can be read, changed, or deleted).

+A - Use the +A option to set the ARCHIVE attribute of a file. When the +A option is used, this flags the file as available for archiving when using the 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 HIDDEN attribute of a file so that it will not appear in a directory listing.

-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 SYSTEM attribute of a file. When the +S option is used, this flags the file as a command file used only by DOS. The file will not appear in a directory listing. 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 within the specified path.

ExamplesThe following form of the command sets the read-only attribute for the file SALES87.TXT:

attrib +r a:sales87.txt

After you have set the read-only attribute for the file SALES87.TXT, DOS will 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 \LETTERS directory on drive B, enter

attrib +a b:\letters\letter3.doc

After the archive bit has been set, commands such as XCOPY can selectively act on them (using the BACKUP or XCOPY /M switch). For more information, refer to the BACKUP and XCOPY command sections.

To determine the current attribute settings for all of the files in the current directory, enter

attrib *.*

The attribute settings for all of the files on the current directory will be displayed. If, for example, you were working in the \LETTERS directory on the diskette in drive B, ATTRIB would display something like this:

A B:\LETTERS\LETTER3.TXT
A R B:\LETTERS\SALES87.DOC
B:\LETTERS\SALES-N.TXT

This display indicates that three files were found and that the first two had the archive bit set. The second file is also marked as read-only.

For more information about this command, refer to the downloadable bookDOS the Easy Way.

Please Log in to join the conversation.

Time to create page: 0.478 seconds