Back to Blog
Arnošt Havelka

Revision 5: Cleanup & Attributes

Master folder deletion and file attribute modification for better system housekeeping.

Start Interactive Lesson
Revision 5: Cleanup & Attributes

Revision 5: Cleanup & Attributes

System maintenance is critical — removing unnecessary files and protecting important ones. In this revision, you'll combine the rd (remove directory) and attrib (attributes) commands to clean up your workspace and secure key files.

Usage:rd
/S /Q
[folder]
/S
Removes the directory tree recursively — deletes all subdirectories and files.
/Q
Quiet mode — suppresses confirmation prompts.
rd
Removes a directory (RD or RMDIR).

Challenge 1: Recursive Cleanup

Use rd with /S (recursive) and /Q (quiet mode) to delete a cache folder and all its contents in one command. This is essential for maintenance — preventing confirmation prompts lets you automate cleanup tasks.

Command Prompt
C:\Users\User>rd /S /Q cache

The /S flag ensures recursive deletion — all subdirectories and files inside cache are removed. The /Q flag suppresses confirmation dialogs, perfect for batch operations.

Challenge 2: File Protection

Now protect an important file by making it read-only using the attrib command. This prevents accidental modifications.

Usage:attrib
+R
[file]
+R
Sets the Read-Only attribute — prevents modifications.
-R
Removes the Read-Only attribute — allows modifications.
+H
Sets the Hidden attribute.
+A
Sets the Archive attribute.
Command Prompt
C:\Users\User>attrib +R settings.ini

The R (Read-Only) attribute in the directory listing shows that settings.ini is now protected. Attempting to delete or modify it will fail until you remove this attribute with attrib -R.


Knowledge Check

1 / 4

What does the /S flag do with the RD command?

References

These Microsoft Learn and Windows documentation links provide authoritative details for the commands used in this article.

Up Next

Opening Files in a Text Editor

Learn to open and edit files with Notepad directly from the command line.