What Is a File Attribute?

List of file attributes in Windows

A file attribute (often just referred to as an attribute or a flag) is a type of metadata that defines a specific condition in which a file or directory can exist.

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.

check list

mohamed Hassan / Pixabay 

What Are the Different File Attributes?

A number of file attributes exist in Windows, including the following:

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:

Here are several additional, albeit more rare, ones recognized by Windows:

  • Device file attribute
  • Integrity file attribute
  • Not content indexed file attribute
  • No scrub file attribute
  • Offline file attribute
  • Sparse file attribute
  • Temporary file attribute
  • Virtual file attribute

You can read more about these on Microsoft's File Attribute Constants page.

Technically there's also a normal file attribute, implying no file attribute at all, but you'll never see this actually referenced anywhere within your normal Windows use.

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.

Screenshot of editing disabled on a file due to the read-only attribute
Read-only Attribute Message.

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.

Screenshot of a folder's attributes in Windows 8
Folder Attributes.

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.

Attributes for Files and Folder in Windows 11
Attributes for Files and Folder (Windows).

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.

attrib command help in Windows 11 command prompt
Attrib Command (Windows 11).

If you're copying read-only files with the xcopy command, use the /k option in the command to retain that file attribute in the destination folder.

Linux operating systems can use the chattr (Change Attribute) command to set file attributes, while chflags (Change Flags) is used in macOS.

immutable bit being set on a JPEG file in Ubuntu
Setting the +i (Immutable) Bit via chattr in Ubuntu.
  • Which attribute is used to hide a file so that it doesn't appear in the directory list?

    The hidden file attribute hides files and folders from the directory. To apply this attribute, right-click a file and select Properties > Hidden. To view all files, including hidden files, from the Command Prompt in Windows, use this dir command option: dir /a.

  • Which file attribute identifies a file as having been modified since the last backup?

    The archive file attribute marks files as modified—or created. Usually, programs turn this attribute on automatically. To manually turn on the attribute, right-click the file > Properties > Advanced > File is ready for archiving. You can also use the attrib +a syntax in the command line.

Was this page helpful?