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 | |
|---|---|
| Item | Explanation |
| attrib | Execute the attrib command alone to see the attributes set on the files within the directory that you execute the command from. |
| +a | Sets the archive file attribute to the file or directory. |
| -a | Clears the archive attribute. |
| +h | Sets the hidden file attribute to the file or directory. |
| -h | Clears the hidden attribute. |
| +i | Sets the 'not content indexed' file attribute to the file or directory. |
| -i | Clears the 'not content indexed' file attribute. |
| +r | Sets the read-only file attribute to the file or directory. |
| -r | Clears the read-only attribute. |
| +s | Sets the system file attribute to the file or directory. |
| -s | Clears the system attribute. |
| +v | Sets the integrity file attribute to the file or directory. |
| -v | Clears the integrity attribute. |
| +x | Sets the no scrub file attribute to the file or directory. |
| -x | Clears the no scrub attribute. |
| drive:, path, filename | This 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. |
| /s | Use 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. |
| /d | This attrib option includes directories, not only files, to whatever you're executing. You can only use /d with /s. |
| /l | The /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
attrib myimage.jpgApply and Clear Attributes
attrib +a f:*.* & attrib -a f:*.bakattrib -h -r -s c:\1.txt /s
Attrib Command Examples

Comments
Post a Comment