• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Attrib \windows\system32\attrib.exe

Change or view the attributes of one or more files or folders.

To Open

Command Prompt attrib

Usage

attrib [+r|-r] [+a|-a] [+s|-s] [+h|-h] [filename] [/s [/d]]

Description

Attrib allows you to change the file and folder attributes from the command line—settings otherwise only available in a file’s or folder’s Properties window. The attributes can be thought of as switches, independently turned on or off for any file or group of files. The individual attributes are as follows:


R (read-only)

Turn on the read-only attribute of a file or folder to protect it from accidental deletion or modification. If you attempt to delete a read-only file, Windows will prompt you before allowing you to delete it. Different applications handle read-only files in different ways; usually you will not be allowed to save your changes to the same filename.


A (archive)

The archive attribute has no effect on how file is used, but it is automatically turned on when a file is modified or created. It is used primarily by a backup software to determine which files have changed since a backup was last performed; most backup programs turn off the archive attribute on each file that is backup.


S (system)

Files with the system attribute are typically used to boot the computer. There’s little reason ever to modify a file with the system attribute, or to ever turn on or off the system attribute for any file. If you turn off the system attribute of an important file, it may stop the file from working. See Notes, below, to display or hide system files.


H (hidden)

To hide any file or folder from plain view in Explorer or on the Desktop, turn on its hidden attribute. See Notes, below, to display or hide hidden files.

Examples

To hide a file in Explorer, right-click on it, select Properties, and turn on the hidden option. To hide the same file using the command line, type:

attrib +h filename

where filename is the full path and filename of the file to change. To specify multiple files, include a wildcard, such as *.* (for all files) or *.txt (for all files with the .txt filename extension). Note the use of the plus sign (+) to turn on an attribute; use the minus sign (-) to turn it off. For example, to turn off the hidden attribute and simultaneously turn on the archive attribute, type:

attrib -h +a filename

To display the attributes of a file or a group of files in Explorer, select Details from the View menu. Then, select Choose Details from the View menu and turn on the Attributes option. To display the attributes of a file or a group of files on the command line, type:

attrib filename

where filename is the full path and filename(s) of the files you wish to view. Omit filename to display the attributes of all the files in the current folder. If filename is not used, or if it contains wildcards (in other words, if the command is intended to act on more than one file), you can use the /s option to further include the contents of all subfolders of the current folder. The /d option instructs Attrib to act upon folders as well as files, but only has meaning if it is used in conjunction with the /s parameter.

Notes

  • By default, files with the system or hidden attributes are not shown in Explorer. To display system and hidden files, go to Explorer Folder Options View and select “Show hidden files and folders.” If hidden and system files are shown, they will appear with faded icons.

  • Attrib allows you to change the system attribute, something you can’t do by right-clicking and selecting Properties. Attrib does not, however, let you change the Advanced attributes, such as those concerned with indexing, compression, or encryption. Note that the “File is ready for archiving” option in the Advanced Attribute window (right-click Properties Advanced) is the same as the Archive attribute just discussed (see Figure 4-9).

Figure 4-9. These advanced attributes are only available from a file’s Properties sheets in Windows Explorer


See Also

“Backup”

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint