Read-Only File Attribute in MS-DOS 6.22
In MS-DOS 6.22, the Read-Only attribute prevents a file from being modified, overwritten, or deleted. This article explains how the Read-Only attribute works, how to view and set it using the native command line, and how to remove it when changes are required.
The Read-Only Attribute
MS-DOS uses file attributes to control how the operating system and user applications interact with files. The Read-Only attribute is represented by the letter R.
When a file has the Read-Only attribute enabled:
- The
DELorERASEcommands will refuse to delete the file, returning an "Access denied" error message. - Programs (such as the MS-DOS Editor) cannot overwrite or save changes directly to the existing file.
- System operations cannot overwrite the file during file copies without explicit prompts or aborts.
How to Check File Attributes
To check whether a file is currently marked as Read-Only, use the
ATTRIB command followed by the filename:
ATTRIB FILENAME.EXT
If the file is Read-Only, an R will appear on the left
side of the output screen next to the file's path.
How to Enable the Read-Only Attribute
To protect a file from modification or deletion, apply the Read-Only
flag using the plus sign (+):
ATTRIB +R FILENAME.EXT
You can also apply this attribute to all files in a directory using wildcards:
ATTRIB +R *.*
To include all subdirectories within a folder, add the
/S switch:
ATTRIB +R *.* /S
How to Remove the Read-Only Attribute
If you need to edit or delete the file later, clear the attribute by
using the minus sign (-):
ATTRIB -R FILENAME.EXT
Once the attribute is removed, the file can be modified or deleted as normal.