Clear Stubborn File Attributes with attrib

Remove hidden, system and read-only flags from files or whole directory trees.

WindowscmdhiddenattributesMedium risk
Run `attrib -h -s -r "<file>"` to clear hidden, system and read-only attributes; use /S /D to apply recursively to a tree.

01Command

Command
$ attrib -h -s -r "D:\USB\file.txt"

02What it does

attrib is the classic way to fix files copied off USB drives that Windows marks hidden and undeletable: -h -s -r removes all three flags in one line. Adding /S processes matching files in subdirectories and /D also processes the folders themselves. The command's syntax is easy to forget because the minus signs belong directly in front of each letter with no spaces.

03Risk

RiskMedium risk
!Warning: Removing the system attribute from protected OS files can expose them to deletion; only clear -s on your own data files.

04Undo

Undo
$ attrib +h +s +r "D:\USB\file.txt"

05Sources

  • attrib - Windows Commands
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents attrib's attribute switches (+R -R, +H -H, +S -S) and the /S /D switches for recursive directory handling.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions