Saturday, July 11, 2009

Changing the Attributes of a File or a Directory [DOS Command]

The Attribute command lets you control the following attributes of a file or directory: read-only, hidden, archive, and system. You can use the Attribute command to control access to a file or a group of files by using read-only and hidden attributes. In short, if a file has the read-only attribute, you can view the contents of a file but can't change it. If a file has the hidden attribute, the file is hidden from view; you won't see it listed when you use the Directory command.

The hidden attribute is particularly useful with directories, both because it can help reduce screen clutter by omitting hidden directories from directory listings and because it can help you hide directories and the files they contain from casual view.

If you're using version 3.2 or a later version of MS-DOS, you can also use the Attribute command to control the archive attribute of a file, which tells MS-DOS (or any other program that checks it) whether the file has been changed since the last time it was backed up for archival storage. Another attribute is the system attribute that is used to tell MS-DOS to treat a file as a system (program) file. If you have version 5 or later, you can use the system attribute. This attribute is normally used only by programmers.

This chapter describes the Attribute command in more detail and shows other examples of its use. The command has the following parameters:

attrib +R -R +A -A +H -H +S -S /S

+R turns on the read-only attribute; -R turns it off.

+A turns on the archive attribute (sometimes called the archive bit); -A turns it off.

+H turns on the hidden attribute; -H turns it off. If you have version 5 or later, you can use the hidden attribute.

+S turns on the system attribute; -S turns it off. If you have version 5 or later, you can use the system attribute.

is the drive, path, and name of the file or directory whose attributes are to be changed or displayed. You can use wildcard characters to specify a group of files. In versions 5 and later, you can omit to view or change the attributes of all files in the current directory. In effect, omitting the parameter in versions 5 and later is the same as specifying as *.*.

/S, in versions 3.3 and later, applies the Attribute command to every file in each subdirectory contained in . If you specify as the root directory of a disk and include /S, the Attribute command is applied to every file in every subdirectory on the disk.

Through version 4 of MS-DOS, if you omit all parameters except , MS-DOS displays the name or names of the files preceded by an A if the file has the archive attribute, an R if the file has the read-only attribute, or both if the file has both attributes set.

In versions 5 and later, omitting all parameters, including if you choose, causes MS-DOS to display the name or names of all files in the current directory. It precedes the file names with A and R for archive and read-only as it does in earlier versions, and uses H and S to indicate the hidden and system attributes.

No comments:

Post a Comment