MS-DOS Commands :: attrib

Overview:

Displays or changes file attributes.

Quick Guide:

Hide/Unhide a Directory:

attrib -h directory

For example, if c:\mystuff\secret\ is hidden then type: attrib -h c:\mystuff\secret\ to unhide it.

To reverse the change and make the directory hidden, type: attrib +h c:\mystuff\secret\

Hide/Unhide a File:

attrib -h filename

For example, if c:\mystuff\secret.txt is hidden then type: attrib -h c:\mystuff\secret.txt to unhide it.

To reverse the change and make the file hidden, type: attrib +h c:\mystuff\secret.txt

Command Variations:

attrib
attrib filename

Display attributes of all the files in the current directory or of only the specified file.

attrib +attribute filename
attrib -attribute filename

For the specified file, either sets (+) or clears (-) the specified attribute attribute:

Attribute Meaning
a Archive
h Hidden
r Read-only
s System

Multiple attributes can be specified at the same time, all as part of one attrib command. The order of the attributes does not matter. For example, to simultaneously clear the hidden attribute and set the read-only attribute of the file mystuff.txt, use: attrib -h +r mystuff.txt

Command Options:

The following examples demonstrate some of the more useful options of the attrib command. For the complet list of options, type attrib /? or help attrib

Hide/Unhide a Directory:

attrib -h directory

For example, if c:\mystuff\secret\ is hidden then type: attrib -h c:\mystuff\secret\ to unhide it.

To reverse the change and make the directory hidden, type: attrib +h c:\mystuff\secret\

Hide/Unhide a File:

attrib -h filename

For example, if c:\mystuff\secret.txt is hidden then type: attrib -h c:\mystuff\secret.txt to unhide it.

To reverse the change and make the file hidden, type: attrib +h c:\mystuff\secret.txt

help attrib

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.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.

(Enlarge: help attrib)