Windows Tip Sheet

Clean Up Your Room

Two-steps to sanity ... er ... a cleaner server.

How often did your mom tell you to pick up after yourself? It's something you probably tell your users as well. It's a sad fact, but occasionally you need to do some housecleaning. Depending on your applications, you may find all sort of backup and temp files that simply need to be cleaned out. Here's an easy, two-step process.

 

 

Tech Help—Just An
E-Mail Away

Got a Windows, Exchange or virtualization question or need troubleshooting help? Or maybe you want a better explanation than provided in the manuals? Describe your dilemma in an e-mail to the MCPmag.com editors at [email protected]; the best questions get answered in this column and garner the questioner with a nifty Redmond T-shirt.

When you send your questions, please include your full first and last name, location, certifications (if any) with your message. (If you prefer to remain anonymous, specify this in your message, but submit the requested information for verification purposes.)

 

First, we'll use the FOR command to create a text file

FOR /f %x in ("~*.*,*.bak,*.tmp,*.dmp") do @DIR E:\Files\%x /s /b >>deleteme.txt

In parentheses and quotes, add all the file extensions you want to find separated by commas. Change the DIR path accordingly. This command will recurse from this directory and record the full path of every file found in the deleteme.txt file. The command will append to deleteme.txt if it already exists, so delete the file before running the command again or use a different file name.

When the command finishes, review deleteme.txt to make sure there's nothing you want to keep. Edit the file as needed. To delete all the files, simply run:

FOR /f "tokens=*" %x in (deleteme.txt) do @DEL "%x"

In no time at all you've have your server cleaned up and you'll be able to go out and play.

I'll come back to these techniques in another column and exploit them further.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025