FreeDOS ATTRIB: Archive, Hidden, Read-Only, and System Flags
Inspect and change FAT file attributes with FreeDOS ATTRIB, understand recursive switches, and avoid treating metadata flags as access controls.
FreeDOS ATTRIB reads or changes the DOS file-attribute flags stored with directory entries. The common flags are Archive, Hidden, Read-only, and System. They help DOS tools classify files and influence display or write/delete behavior, but they are not user identities, access-control lists, encryption, or a dependable security boundary. Correct use starts with a precise filespec and a read-only inspection; recursive wildcards can affect many files quickly, and removing attributes from an entire system tree may make protected files easier to alter or delete.
The four familiar flags
The Archive attribute, written A, conventionally marks a file that has changed since an application or backup program last processed it. The FreeDOS ATTRIB documentation describes it as set when a file is modified and notes that backup utilities can clear it after backup. That makes it a useful hint for incremental tools, not an authoritative backup ledger. A program may not preserve the convention, a backup may not clear it, and a copied file can have attributes different from its source.
Hidden (H) keeps a file out of an ordinary FreeDOS DIR listing; wildcard matching depends on the command’s attribute rules. FreeDOS DIR /A includes hidden and system files in wildcard matches, while an ordinary listing omits them. The flag is a convenience for keeping routine files out of view, not a way to keep data secret. Read-only (R) tells DOS-aware operations that the file should not be changed; a program may prompt, fail, or deliberately override it. System (S) is used for files that DOS tools treat specially, and the FreeDOS help notes that such a file is protected from some delete/overwrite operations. The exact behavior is tool-specific: another utility or direct disk operation may not honor the same policy.
FAT stores attributes as metadata bits in directory entries. They do not encode a user or group, and there is no built-in per-user permission model behind them. A hidden file is still readable by a program that knows its name; a read-only bit does not stop a process with sufficient ability to change the metadata or write raw sectors. Do not use ATTRIB as the only safeguard for data that must be confidential or immutable.
Inspect first, then change one target
With no attribute modifier, ATTRIB displays state for its target files. A narrow inspection is safer than starting with a broad wildcard:
C:\>ATTRIB C:\DATA\REPORT.DAT
The output letters show which flags are set. Confirm the drive, directory, and filename before making a change. If a name includes spaces under a long-filename driver, quote it according to the installed command’s documented syntax and test on a harmless file; classic DOS utilities can differ in long-filename support. A DOS 8.3 alias can avoid quoting ambiguity on systems without DOSLFN.
To remove only the Read-only flag from one known file, use:
ATTRIB -R C:\DATA\REPORT.DAT
To set the Archive flag on a file, use ATTRIB +A C:\DATA\REPORT.DAT. Use explicit + or - for each attribute you intend to change; do not copy a broad -R -H -S recipe unless you have verified every target needs all three changes. A change to metadata can alter how other commands see or manipulate the file, even though its content bytes remain unchanged.
Wildcards and recursion require a scope check
The FreeDOS syntax supports /S to process files in the specified paths and their directories, and /D to process directory names for wildcard arguments. The distinction is important. A command such as ATTRIB +R C:\PROJECT\*.DAT /S can set Read-only on every matching data file through the tree. Adding /D changes the target set by allowing directory names to participate when the argument contains wildcards. Do not infer that a switch affects only files with a matching leaf name or only the top directory.
Before running a recursive mutation, enumerate the intended set using DIR /A /S with an explicit path so Hidden and System entries are not silently omitted, then inspect the results. If the target list is large, test against a copied sample directory first. Avoid running ATTRIB -R C:\*.* /S from a system volume: it can remove the flag from many files, including system-managed content, and make accidental edits possible. A current-directory-dependent command is especially risky in batch files because CD or drive selection may differ from what the author expects.
ATTRIB also documents /@ for processing file names from a list file or standard input. Use that mode only after verifying the list format and the implementation installed on the machine. A stale list, malformed path, or unexpected working directory can broaden the operation. For a one-off repair, explicit file paths are easier to review and reproduce.
The Archive bit and backup workflows
Incremental backup programs often use the Archive bit as a cheap “changed since last backup” marker. ATTRIB can set or clear it, but clearing the bit does not prove a backup exists. If the backup tool clears the bit after reading but before writing a verified copy, a failure can leave a file marked as backed up even though no good backup was created. Conversely, software may set or preserve Archive for reasons unrelated to a specific backup run.
For a backup workflow, record the files the program actually copied, verify the destination, and then let the backup program manage archive flags if that is its documented model. Manually clearing Archive with ATTRIB -A on a broad set can cause a later incremental run to skip files. Manually setting it can cause extra copying but is generally a less dangerous mismatch than clearing it; still, test the tool’s behavior before depending on the bit.
Do not confuse FAT modification time with Archive state. FAT timestamps have limited precision and no timezone field, while the Archive flag is a separate one-bit hint. A file can have a recent timestamp with Archive clear, or the opposite. An archive tool may also store timestamps and attributes differently from a DOS directory entry. Use a content comparison or trusted digest for integrity, not metadata alone.
Read-only files and removal operations
Read-only is frequently the reason a DOS utility refuses to overwrite or delete a file. The safe procedure is to inspect the exact file, remove only R, perform the intended operation, and restore the flag only if the file’s role requires it. Do not clear Read-only recursively just to eliminate a prompt. The prompt is useful evidence that the target has a special state and gives an operator an opportunity to reconsider.
Hidden and System flags can also affect tools that enumerate files. A copy or archive program may omit them unless instructed otherwise. If a backup seems incomplete, inspect attributes and the utility’s documented inclusion rules before assuming the files vanished. Likewise, when cleaning temporary directories, remember that recursive deletion tools may ignore attributes entirely; setting R or H is not a reliable protection against DELTREE.
Batch and error handling
FreeDOS ATTRIB documents distinct error levels: success/help, attribute-change failure, no matching files, list-file open failure, and command-line error. A batch script should treat “no match” differently from “could not change attributes,” and should preserve the command’s error result before running another command that may replace ERRORLEVEL.
For classic DOS batch syntax, IF ERRORLEVEL n means “n or greater,” so test higher error codes first. A diagnostic pattern for a known file might be:
ATTRIB -R C:\DATA\REPORT.DAT
IF ERRORLEVEL 4 GOTO BAD_SYNTAX
IF ERRORLEVEL 3 GOTO BAD_LIST
IF ERRORLEVEL 2 GOTO NO_MATCH
IF ERRORLEVEL 1 GOTO CHANGE_FAILED
Adapt the labels and codes to the ATTRIB version you actually ship. The pattern intentionally does not assume that a newer utility clone has identical error values. First run the command manually against a disposable file and record ATTRIB /? and the output on the target installation.
Safe operational checklist
Before a broad change, write down the intended directory and exact flags. Confirm the current drive with CD and verify the target with DIR/ATTRIB. Use one file first, then a limited wildcard, and only then recursion if necessary. Re-run ATTRIB afterward to confirm metadata, but also check the file’s content if a tool may have changed it. Keep a copy of the original attribute list when adjusting a large tree so the change can be reviewed or reversed.
For a system that uses DOSLFN, network redirectors, or a third-party filesystem driver, test the command against a disposable long-name file and remote share before relying on its behavior. The basic FreeDOS help documents the command interface, but compatibility details can be determined by the installed executable and filesystem stack. State these dependencies in scripts rather than treating all DOS environments as identical.
Related:
- How to Archive FreeDOS Files Without Losing Names or Metadata
- FAT12 and FAT16 Internals: The Filesystem Behind FreeDOS
Sources: