Attrib Command Examples

'Attrib' Command Syntax & Switches

The command takes the following general form:

attrib [+a|-a] [+h|-h] [+i|-i] [+r|-r] [+s|-s] [+v|-v] [+x|-x] [drive:][path][filename] [/s [/d] [/l]]

If you're not sure how to interpret the attrib command syntax you see above or shown in the table below, it's advised to learn how to read command syntax.

Attrib Command Options
ItemExplanation
attribExecute the attrib command alone to see the attributes set on the files within the directory that you execute the command from.
+aSets the archive file attribute to the file or directory.
-aClears the archive attribute.
+hSets the hidden file attribute to the file or directory.
-hClears the hidden attribute.
+iSets the 'not content indexed' file attribute to the file or directory.
-iClears the 'not content indexed' file attribute.
+rSets the read-only file attribute to the file or directory.
-rClears the read-only attribute.
+sSets the system file attribute to the file or directory.
-sClears the system attribute.
+vSets the integrity file attribute to the file or directory.
-vClears the integrity attribute.
+xSets the no scrub file attribute to the file or directory.
-xClears the no scrub attribute.
drive:, path, filenameThis is the file (filename, optionally with drive and path), directory (path, optionally with drive), or drive that you want to view or change the attributes of. Wildcard use is allowed.
/sUse this switch to execute whatever file attribute display or changes you're making on the subfolders within whatever drive and/or path you've specified, or those within the folder you're executing from if you don't specify a drive or path.
/dThis attrib option includes directories, not only files, to whatever you're executing. You can only use /d with /s.
/lThe /l option applies whatever you're doing with the attrib command to the Symbolic Link itself instead of the target of the Symbolic Link. The /l switch only works when you're also using the /s switch.
/?Use the help switch with the attrib command to show details about the above options right in the Command Prompt window. Executing attrib /? is the same as using the help command to execute help attrib.

In Recovery Console, +c and -c switches apply to attrib. They set and clear the compressed file attribute, respectively. Outside of this diagnostic area in Windows XP, use the compact command to handle file compression from the command line.

Display a File's Attributes

attrib myimage.jpg

Apply and Clear Attributes

attrib +a f:*.* & attrib -a f:*.bak


 attrib -h -r -s c:\1.txt /s


Attrib Command Examples

Comments

Popular posts from this blog