CMD Master
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

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.

Try the command

Delete a cache folder with all contents automatically!

Build the command
rd[arguments]
Terminal
C:\Users\Student>rd /S /Q cache

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.

Terminal
C:\Users\Student>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.

Try the command

Make a configuration file read-only!

Build the command
attrib[arguments]
attrib
Terminal
C:\Users\Student>attrib +R settings.ini
Terminal
C:\Users\Student>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 documentation links provide authoritative details for the commands used in this article.

Up Next

How to Create a Text File in CMD with copy con

Create a small text or batch file in CMD without Notepad: start copy con, enter each line, then press Ctrl+Z and Enter to save.