Using the ATTRIB Command in MS-DOS 6.22

In MS-DOS 6.22, file attributes are managed through the external utility ATTRIB.EXE, which allows users to view, set, and clear critical file metadata flags. This command works directly with the File Allocation Table (FAT) file system by modifying the dedicated attribute byte in a file's directory entry. By manipulating these attributes—specifically Read-Only, Archive, Hidden, and System—MS-DOS 6.22 controls how files interact with basic operating system operations such as file editing, directory listings, and automated backup routines.

The Four File Attributes

MS-DOS 6.22 tracks four distinct file attributes, each assigned a specific letter in the command syntax:

  • R (Read-Only): Prevents the file from being altered, overwritten, or deleted by standard DOS commands like DEL.
  • A (Archive): Indicates that a file has been modified since the last backup. Backup utilities (such as MSBACKUP or XCOPY /M) inspect and clear this flag to track incremental changes.
  • S (System): Marks a file as an operating system component. System files are hidden from standard directory listings and are protected from accidental deletion.
  • H (Hidden): Prevents a file from appearing in a standard DIR listing unless the /A switch is used.

Command Syntax and Operations

The basic syntax for the command in MS-DOS 6.22 is:

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename] [/S]

To modify an attribute, a prefix is placed directly before the attribute letter:

  • + (Plus sign): Sets or enables the attribute.
  • - (Minus sign): Clears or disables the attribute.

Multiple attributes can be combined into a single command string. For example, to apply both Hidden and Read-Only attributes simultaneously:

ATTRIB +R +H C:\DATA\DOC.TXT

To process files recursively through all subdirectories beneath a target location, the /S switch is appended to the end of the command:

ATTRIB +R C:\FILES\*.* /S

Executing ATTRIB followed simply by a file path or wildcard (with no flags) outputs the current attribute status for the specified files.

Under the Hood: The FAT Directory Entry

When the ATTRIB command executes in MS-DOS 6.22, it does not modify the data contents of the file itself. Instead, it interacts directly with the FAT12 or FAT16 directory structure.

Every file in MS-DOS has a 32-byte directory entry record. Offset 0x0B of this record is reserved for the file attribute byte, which stores attributes as individual bit flags:

  • Bit 0 (0x01): Read-Only
  • Bit 1 (0x02): Hidden
  • Bit 2 (0x04): System
  • Bit 3 (0x08): Volume Label
  • Bit 4 (0x10): Subdirectory
  • Bit 5 (0x20): Archive

When ATTRIB modifies a file, MS-DOS performs a bitwise operation on offset 0x0B. If +H is supplied, MS-DOS performs a bitwise OR with 0x02. If -H is supplied, it performs a bitwise AND with the inverted mask. Once computed, the modified 32-byte directory sector is written back to the disk.

System and Hidden Attribute Handling

Earlier versions of MS-DOS placed strict restrictions on clearing or setting System and Hidden flags, often refusing to modify other attributes on a file if the System or Hidden flags were already active.

In MS-DOS 6.22, ATTRIB.EXE allows users to manipulate the System and Hidden attributes freely alongside the Read-Only and Archive flags in a single execution. However, if a file already possesses the System or Hidden attribute, you must explicitly clear or include those flags when attempting to alter other attributes on that file, preventing accidental exposure of sensitive system files like IO.SYS or MSDOS.SYS.