Understanding Windows File Attributes
We use digital files every day, but it’s relatively rare we need to recognize the attributes of a digital file. This article is all about understanding File Attributes in Windows.
You might for example have wondered how the Windows operating system differentiates files that are visible from those that are hidden. Or let’s say a text editor program pops up an error message informing you the file is “read-only” when you’re trying to save changes to the file - you might ask yourself: how does the text editor know that the file is read-only? File Attributes tag files with additional information that Windows uses to act on.
Knowing a little about File Attributes will help you understand why certain things happen with files, and why certain things can’t happen if an attribute is defined in a certain way.
What are File Attributes and What are They Used For?
File attributes are pieces of information associated with every file and directory that includes additional data about the file itself or its contents. They can exist in only one of two states – Set or Cleared; like an On or Off state. Attributes can be in files, directories, volumes and certain system objects. They are used by the operating system and software applications to define file system behavior.
Listing of the Commonly Used Attributes
A byte stores the attributes of a file, with each specific attribute assigned to a bit of a byte. To enable a certain attribute, the system will assign a "one" to the corresponding bit, which represents the "On" state. These are referred to as flagging or setting the attribute. A Windows operating system (Win32) stores the file attributes as 32-bit quantity, while the original MS-DOS file attributes only have 8 bits to store file attributes.
Below are the common attributes and the bits that represent them:
Attribute | What it Does | Common Use Case |
---|---|---|
Read-Only (R) | Prevents a file from being accidentally modified or saved over. | Protecting important configuration files or documents from changes. |
Hidden (H) | Hides the file or folder from normal view in File Explorer. | Decluttering views by hiding system files or user-specific application data. |
System (S) | Marks a file as a critical operating system file. These are typically hidden and protected. | Protecting core Windows files from being accidentally deleted or moved. |
Archive (A) | A flag used by backup software to identify files that have been created or modified since the last backup. | Enabling efficient incremental and differential backups. Most backup programs clear this bit after a backup and it gets set again when the file is changed. |
Not Content Indexed (I) | Excludes the file or folder from the Windows Search indexer. | Preventing temporary files or private folders from appearing in search results, which can also slightly improve indexing speed. |
Directory (D) | Indicates it is a directory, not a file. | Files go into directories. |
A file, or directory, may have more than one attribute mapped to it. For example, you can have a read-only, hidden file. Below are the descriptions of each attribute:
Some applications may modify files without marking the archive attribute. If the backup software uses incremental backups to backup these files, it will rely on the software to set the bit appropriately. It is therefore important to note that you should not rely solely on this setting to ensure critical files are backed up.
How to View and Modify attributes?
There are a few ways to view and change attributes. Two of them are via the file or folder properties from Windows Explorer or using the ATTRIB command from MS-DOS prompt (type CMD command to bring up the DOS window).
Viewing Attributes from Windows Explorer
Right-clicking and selecting Properties on any file or folder in Windows Explorer will bring up the Properties window, which shows the attributes of the selected item.
Note: The extended attributes (compress and encrypt) will not be shown when you use the ATTRIB command. However, you can view these attributes by executing the Compact and Cipher commands, respectively.
Viewing Attributes from DOS prompt
To view attributes, you can type ATTRIB command from the DOS prompt.
Typing
ATTRIB /?
will bring up a list of all the syntax available to query a file.
To view what attributes are assigned to a file, type the following:
ATTRIB C:\Folder\Filename.ext
From here, we can see that the TEST.TXT file has the Archive, Hidden and Read-Only attribute enabled (A, H & R are shown).
Using the ATTRIB command allows a user to Set or Clear an attribute of a file. For the above example, if we wish to remove the attribute of Hide and Read-Only from the file, we could type:
ATTRIB -H -R C:\FOLDER\TEST.TXT
The example above shows that the hidden and Read-Only attribute have been removed from TEST.TXT.
Using PowerShell (The Modern Way)
Using PowerShell, you can get the attributes using Get-ItemProperty:
Get-ItemProperty -Path "filename" | Select-Object Attributes
To change the attributes, use Set-ItemProperty:
Set-ItemProperty -Path "filename" -Name IsReadOnly -Value $true
Conclusion
This article has hopefully helped you understand a little more about Windows file attributes. Being familiar with file attributes will help you better understand how the file system works in a Windows environment. You could use this knowledge to your advantage by selecting the Fast Backup (scanning the Archive Attribute) option in SyncBackSE and SyncBackPro to greatly reduce the time needed for each backup, thereby increasing your productivity and freeing up your system resources for other tasks.