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 editor@mcpmag.com; 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 a multi-year Microsoft MVP in Windows PowerShell, Microsoft Certified Professional and an IT veteran with almost 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 works today as an independent author, trainer and consultant. Jeff is a regular contributor to a variety on online sites, as well as frequent speaker at technology conferences and user groups. Keep up with Jeff and his projects at http://jdhitsolutions.com/blog.

comments powered by Disqus

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.