tree and attrib: see folder structure and file attributes
Two small commands that answer questions File Explorer makes awkward: what does this whole folder look like, and why is this file hidden or impossible to change?
tree: a picture of a folder
tree draws the folders inside the current one as a diagram.
C:\Users\asha\demo>tree /a
Folder PATH listing
Volume serial number is 1A2B-3C4D
C:.
+---old
\---photosThe first two lines name the disk. The diagram starts at the dot, which stands for the current folder.
By default it shows only folders. Add /f to include the files.
C:\Users\asha\demo>tree /f /a
Folder PATH listing
Volume serial number is 1A2B-3C4D
C:.
| log.txt
| marks.csv
| notes.txt
| report.txt
|
+---old
| draft.txt
|
\---photos
beach.jpg
hills.jpg
The /a switch draws the lines with ordinary characters, which copy and print reliably. Without it, tree uses line-drawing characters that some programs show as odd symbols.
Give a path to draw another folder: tree /f /a photos.
Saving the picture
A folder diagram is useful in documentation, or to show someone how a project is laid out. Send it to a file:
C:\Users\asha\demo>tree /f /a > structure.txt
C:\Users\asha\demo>type structure.txt
Folder PATH listing
Volume serial number is 1A2B-3C4D
C:.
| log.txt
| marks.csv
| notes.txt
| report.txt
| structure.txt
|
+---old
| draft.txt
|
\---photos
beach.jpg
hills.jpg
On a big folder the output is long. Pipe it through more to read it a screen at a time, or send it to a file and open that in Notepad.
attrib: file attributes
Every file carries a few on-off markers called attributes. attrib shows them.
C:\Users\asha\demo>attrib
A C:\Users\asha\demo\log.txt
A C:\Users\asha\demo\marks.csv
A C:\Users\asha\demo\notes.txt
A C:\Users\asha\demo\report.txt
A C:\Users\asha\demo\structure.txtThe letters in the left margin are the attributes that are switched on.
| Letter | Attribute | Meaning |
|---|---|---|
R | read-only | programs should not change or delete the file |
H | hidden | not shown in ordinary listings |
S | system | belongs to Windows; hidden even more firmly |
A | archive | changed since it was last backed up |
Most ordinary files show just A.
Setting and clearing attributes
A plus sign switches an attribute on. A minus sign switches it off.
C:\Users\asha\demo>attrib +r notes.txt
C:\Users\asha\demo>attrib notes.txt
A R C:\Users\asha\demo\notes.txt
C:\Users\asha\demo>del notes.txt
C:\Users\asha\demo\notes.txt
Access is denied.The delete was refused, because the file is now read-only. Clearing the attribute allows it again.
C:\Users\asha\demo>attrib -r notes.txt
C:\Users\asha\demo>attrib notes.txt
A C:\Users\asha\demo\notes.txtHiding a file
C:\Users\asha\demo>attrib +h marks.csv
C:\Users\asha\demo>dir /b
log.txt
notes.txt
old
photos
report.txt
structure.txt
C:\Users\asha\demo>dir /b /a
log.txt
marks.csv
notes.txt
old
photos
report.txt
structure.txt
C:\Users\asha\demo>attrib -h marks.csvAfter +h, the plain dir no longer lists the file, but dir /a does. Hiding is a convenience, not security. Anyone can show hidden files with one setting in File Explorer or one switch on dir.
A whole folder
/s applies the change to matching files in all subfolders, and /d includes the folders themselves.
attrib -h -r /s /d *.*This form is well known for recovering files on a USB drive that a virus has hidden. If the files on a pen drive seem to have vanished while the used space is unchanged, they have usually been given the hidden and system attributes. On the drive, attrib -h -r -s /s /d *.* makes them visible again. Scan the drive with antivirus software as well, since something set those attributes.
Danger. Do not clear the system and hidden attributes across your Windows drive. Windows hides certain files so that they are not moved or deleted by accident. Use these commands on your own data folders and removable drives.
Why is a file read-only?
- It was copied from a CD or DVD, where everything is read-only.
- Someone set the attribute to protect it.
- It came from an email attachment or a download that a program marked that way.
Clearing the attribute with attrib -r is all that is needed. If you still cannot change the file after that, the cause is permissions, not attributes, and the Security tab of the file's Properties is the place to look.
The archive attribute
Windows switches A on whenever a file is created or changed. Backup programs can copy only the files that have it and then switch it off, so that the next backup takes only what changed since. xcopy /m works this way.
On Linux and the Mac, files have permissions instead of attributes. See chmod.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.