Attrib Command

Attrib Command Examples, Switches, Options, and More

Screenshot of the attrib command and help switch in Windows 10 Command Prompt
Attrib Command (Windows 10).
Was this page helpful?

The attrib command is a Command Prompt command used to display or change the file attributes for a file or folder.

You can also find and set most file and folder attributes in Windows Explorer by right-clicking the object and going into its Properties > General tab.

Attrib Command Availability

The attrib command is available in the Command Prompt in all Windows operating systems including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, plus older versions of Windows as well.

All offline diagnostic and repair tools available with the various versions of Windows, including Advanced Startup Options, System Recovery Options, and Recovery Console, also include the attrib command in some capacity.

This attrib command is also available in MS-DOS as a DOS command.

Note: The availability of certain attrib command switches and other attrib command syntax might differ from operating system to operating system.

Attrib Command Syntax & Switches

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

Tip: See How to Read Command Syntax if you're not sure how to interpret the attrib command syntax you see above or shown in the table below.

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.

Note: In Recovery Console, +c and -c switches are available for the attrib command, which 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.

When a wildcard is allowed with the attrib command, it means that you can use the * symbol to apply the attribute to a group of files.

However, if applicable, you have to clear the system or hidden attribute first before you can change any of the file's other attributes.

Attrib Command Examples

attrib +r c:\windows\system\secretfolder

In the above example, the attrib command is used to turn on the read only attribute, using the +r option, for the secretfolder directory located in c:\windows\system.

attrib -h c:\config.sys

In this example, the config.sys file located in the root directory of the c: drive has its hidden file attribute cleared by use of the -h option.

attrib -h -r -s c:\boot\bcd

This time, the attrib command is used to remove multiple file attributes from the bcd file, an important file that must be working for Windows to start. In fact, executing the attrib as shown above is a key part of the process outlined in our How to Rebuild the BCD in Windows tutorial.

attrib myimage.jpg

To end with a simple attrib example, this one simply displays the attributes of a file named myimage.jpg.

Attrib Command Errors

Like with most commands in Command Prompt, remember to use double-quotes around a folder or file name that has spaces. If you forget to do this with the attrib command, you'll get a "Parameter format not correct -" error.

For example, instead of typing my folder in Command Prompt to show the path to a folder by that name, you'd type "my folder" to utilize the quotes.

Attrib command errors like "Access Denied" mean that you don't have enough access to the file(s) you're trying to make attribute changes to. Take ownership of those files in Windows and then try again.

Changes in the Attrib Command

The +i, -i, and /l attrib command options were first available in Windows Vista and have been retained up through Windows 10.

The +v, -v, +x, and -x switches for the attrib command are only available in Windows 7, Windows 8, and Windows 10.

Attrib Related Commands

It's common for the xcopy command to affect a file's attribute after it backs up something. For example, the xcopy command's /m switch turns off the archive attribute after the file has been copied.

Similarly, the xcopy /k switch keeps a file's read-only attribute once it's been copied.