An attribute can exist in one of two states, so it’s considered either set or cleared at any given time, meaning it’s either enabled or isn’t. Computer operating systems, like Windows, can tag data with specific file attributes so that it can be treated differently than data with an attribute turned off. Files and folders aren’t actually changed when attributes are applied or removed, they’re just understood differently by the operating system and other software.
What Are the Different File Attributes?
A number of file attributes exist in Windows, including the following:
Archive file attribute Directory attribute Hidden file attribute Read-only file attribute System file attribute Volume label attribute
The following were first available to the Windows operating system with the NTFS file system, meaning they aren’t available in the older FAT file system:
Compressed file attribute Encrypted file attribute Indexed file attribute
Here are several additional, albeit more rare, ones recognized by Windows:
Device file attributeIntegrity file attributeNot content indexed file attributeNo scrub file attributeOffline file attributeSparse file attributeTemporary file attributeVirtual file attribute
You can read more about these on Microsoft’s File Attribute Constants page.
Why Are File Attributes Used?
File attributes exist so that you, or a program you’re using, or even the operating system itself, can be granted or denied particular rights to a file or folder. Learning about common file attributes can help you understand why certain files and folders are referred to as “hidden” or “read-only,” for example, and why interacting with them is so different than interacting with other data. Applying the read-only file attribute to a file will prevent it from being edited or changed in any way unless the attribute is lifted to allow write access. The read-only attribute is often used with system files that shouldn’t be altered, but you could do the same with your own files that you’d rather someone with access not edit. Files with the hidden attribute set will actually be hidden from normal views, making them really difficult to accidentally delete, move, or change. The file still exists like every other file, but because the hidden attribute is toggled, it prevents the casual user from interacting with it. You can set Windows to view hidden files and folders as an easy way to see these files without toggling the attribute off. You can also combine attributes so that a file is, for example, not only hidden but also marked as a system file and set with the archive attribute.
File Attributes vs. Folder Attributes
Attributes can be toggled on and off for both files and folders, but the consequences of doing so differ a bit between the two. When a file attribute like the hidden attribute is toggled on for a file, that single file will be hidden, nothing else. If the same attribute is applied to a folder, you’re given more options than to just hide the folder: you have the option to apply the attribute to the folder alone or to the folder, its subfolders, and all of its files. Applying this file attribute to a folder’s subfolders and its files mean that even after you open the folder, all the files and folders that are contained within it will be hidden as well. The first option of just hiding the folder alone would make the subfolders and files visible, but just hide the main, root area of the folder.
How File Attributes Are Applied
Although all the available attributes for a file have common names, which you saw in the lists above, they aren’t all applied to a file or folder in the same way. A small selection of attributes can be turned on manually. In Windows, you can do this by right-clicking (or tap-and-hold on touch interfaces) a file or folder, opening its properties, and then enabling or disabling an attribute from the list provided. In Windows, a larger selection of attributes can also be set with the attrib command, available from Command Prompt. Having attribute control via a command allows third-party programs, like backup software, to easily edit file attributes. Linux operating systems can use the chattr (Change Attribute) command to set file attributes, while chflags (Change Flags) is used in macOS.