How to view and change file attributes
Overview
Windows attributes label files as read-only, hidden, system, or archive. attrib displays and changes those flags.
An attribute is metadata, not encryption or access control. Hidden files can still be listed, and read-only may not prevent every program from changing data.
- Letters include
Rread-only,Hhidden,Ssystem, andAarchive. - A plus sign sets an attribute; a minus sign clears it.
- Use
dir /ato include hidden items in a listing.
Commands to try
Type each command at the prompt, then press Enter. Replace sample names and paths with ones that exist on your computer.
Commands are generally not case-sensitive, but preserving the spelling shown here makes scripts easier to read.
attrib notes.txt
attrib +r notes.txt
attrib -r notes.txt
attrib +h private-note.txt
attrib -h private-note.txt
attrib /s /d Practice\*
Useful options and details
Options change how a command behaves. Add spaces exactly as shown, and use the command's built-in help when an option is unfamiliar.
A path containing spaces must be enclosed in double quotes, such as "C:\My Files".
/sprocesses matching files in subfolders./dincludes directories when used with/s.- Wildcards select multiple names and deserve a preview.
Tips and common mistakes
Check the current folder and read the command output before assuming an operation succeeded.
Practice with disposable files first. Commands that delete, overwrite, or stop a process may not offer an Undo button.
- Do not remove system or hidden flags from Windows-managed files.
- A hidden attribute is not a privacy feature.
- Some cloud-sync and application behavior may change attributes automatically.
Safe practice
Create a temporary practice folder under your user profile so the examples cannot affect Windows system files.
After each command, inspect the result with dir or another read-only command before continuing.
- Create a disposable file and inspect its attributes.
- Set and clear read-only, checking after each command.
- Temporarily hide it and find it with
dir /a.