The attrib command displays or changes the file attributes for a file or folder. It’s run from the Command Prompt in all versions of Windows.
‘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 attrib in some capacity.
This attrib command is also available in MS-DOS as a DOS command.
‘Attrib’ Command Syntax & Switches
The command takes the following general form:
The availability of certain attrib command switches and other attrib command syntax might differ from operating system to operating system.
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.
When a wildcard is allowed with attrib, it means that you can use an asterisk 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.
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.
Attrib Command Examples
attrib +r c:\windows\system\secretfolder
In the above example, attrib turns 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, attrib removes several file attributes from the bcd file, an important file that must be working for Windows to start. In fact, executing the attrib command, as shown above, is a key part of the process outlined in the steps necessary for rebuilding the BCD in Windows.
attrib +a f:. & attrib -a f:*.bak
With the above example, we’re applying +a to set the archive attribute on all files that exist on the f: drive, but then using & to remove the archive attribute on every file on f: that has the .bak file extension.
attrib myimage.jpg
To end with a simple attrib example, this one simply displays the attributes of a file named myimage.jpg. If you were to remove the second half and execute only the attrib command, it would display the attributes for all files in the current directory.
In the above example, BAK files indicate files that have already been backed up, meaning that they don’t need to be archived/backed up again, hence the need to remove the archive attribute.
Attrib Command Errors
As with most commands in Command Prompt, 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 use 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 effect 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.
Viewing Attributes in Explorer
You can also view and manage attributes for files and folders in Explorer using regular menu buttons. This might be preferred for you if you’re not familiar with the command line.
Do this by right-clicking the object and going into its Properties > General tab.
Get the Latest Tech News Delivered Every Day
Copy Command
What Is a File Attribute?
Xcopy Command
Vol Command Examples and Options
Rename Command
More Command
Net Send Command
How to Use the Netstat Command
Sfc Command (System File Checker)
Windows 7 Command Prompt Commands
Net Command
How to Change the Windows Startup Sound
How to Rebuild the BCD in Windows
Fixboot Command (Recovery Console)
How to Use the Chkdsk Command in Windows
What Is an Archive File Used For?
Facebook
Twitter
Hit Refresh on Your Tech News
About Us
Privacy Policy
Editorial Guidelines
Terms of Use
Careers
Advertise
Contact
EU Privacy
NEWS
HOW TO
FEATURES
ABOUT US