Click here to Skip to main content
Click here to Skip to main content

A Utility to Clean Up Compiler Temp Files

, 24 Dec 2002
Rate this:
Please Sign up or sign in to vote.
A shell extension that deletes compiler temp and intermediate files.

 [DirClean menu items - 9K]

Recently at work, I was talking with a coworker about cool little utilities that we wished we had. He mentioned an idea for a shell extension that would remove all intermediate compiler files (such as *.obj) from a directory (and recurse subdirectories, naturally). That sounded pretty neat, and since he was in the middle of writing up a different cool program, I decided to get cracking on the clean-up utility and see what I could do.

I came up with this little app, DirClean. It's a shell extension that appears on the context menu of directories, and has a "Clean up temp files" command that will remove intermediate compiler files from the selected directory and its subdirectories. By default, the files are put in the Recycle Bin, but you can configure DirClean to just delete the files instead. DirClean uses the SHFileOperation function to delete files, so if there are a lot of files to delete, you'll see the familiar flying-paper progress dialog.

DirClean has both ANSI and Unicode versions. It was written with VC 6 SP 3, and tested on Win 98 and Win 2000.

The "DirClean options" menu item brings up the DirClean options dialog:

 [DirClean options - 9K]

The settings here should be self-explanatory. I don't do any checking of the wildcards you enter, so you probably don't want to enter "*.*" Wink | ;) The settings are saved in HKEY_CURRENT_USER, so each user has his own settings.

Note that you can override the "Send files to the Recycle Bin" setting by holding down the Shift key when clicking "Clean up temp files." Holding in Shift will immediately delete files if you have the option set to send files to the Recycle Bin, and vice versa.

Important note for VS.NET users

On the NT-based OSes, the way that the shell handles extensions of more than 3 characters will cause problems for C# projects. The default behavior of the shell makes the wildcard *.res match .RESX files (it only compares the first three characters), and deleting the .RESX files will delete some resource information.

So, to avoid deleting those files, you can either remove *.res from the list of files to delete, or go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, and set the DWORD value Win95TruncatedExtensions to 0, then restart your computer. See KB article Q164351 for more info on this feature.


Oct 28, 2001 - Default list of wildcards updated.
Dec 25, 2002 - Added note about the Win95TruncatedExtensions registry entry.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Michael Dunn
Software Developer (Senior) VMware
United States United States
Michael lives in sunny Mountain View, California. He started programming with an Apple //e in 4th grade, graduated from UCLA with a math degree in 1994, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.
Mike has been a a developer at Napster and at his own lil' startup, Zabersoft, a development company he co-founded with offices in Los Angeles and Odense, Denmark. Mike is now a senior engineer at VMware.

He also enjoys his hobbies of playing pinball, bike riding, photography, and Domion on Friday nights (current favorite combo: Village + double Pirate Ship). He would get his own snooker table too if they weren't so darn big! He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.
Mike was a VC MVP from 2005 to 2009.

Comments and Discussions

GeneralPlease add subfolders PinmemberAnonymous31-Oct-01 13:41 
GeneralRe: Please add subfolders PinmemberCoder2-Nov-01 3:27 
GeneralRe: Please add subfolders PinsussAnonymous16-Oct-02 6:45 
GeneralRe: Please add subfolders PinmemberMichael Dunn2-Nov-01 9:30 
GeneralTHANK YOU! PinmemberGreven31-Oct-01 7:04 
GeneralWe dont need a utility to do that! PinmemberAnonymous29-Oct-01 6:21 
GeneralRe: We dont need a utility to do that! PinmemberWilliam E. Kempf29-Oct-01 12:30 
GeneralRe: We dont need a utility to do that! PinmemberAnonymous29-Oct-01 15:40 
GeneralRe: We dont need a utility to do that! PinmemberSardaukar30-Oct-01 6:47 
QuestionUnregister / uninstall - how? Pinmembermarkuea14-Oct-01 7:45 
AnswerRe: Unregister / uninstall - how? PinmemberMichael Dunn14-Oct-01 9:23 
QuestionErr.. how to register the dll? PinsussRobin2-Aug-00 0:06 
AnswerRe: Err.. how to register the dll? PinsussMike Dunn2-Aug-00 7:51 
QuestionHow to Add Separators or Submenus to ... PinsussDavid L.9-Jun-00 22:14 
I'm sorry if this is abit off topic to this particular article. I've read and love Mr. Dunn's articles on Shell extensions
among others and they are great. I was wondering if anyone has seen an article or know how to add
menu separators or submenus (like Winzip) to a context menu extension. If someone could point me in the
right direction or would be great if Mr. Dunn might make one of his next article on this Smile | :) The other thing is
I noticed he has an entry in his context menu (screen shot) for 'Add Item to Desktop' ... that would be a handy
feature I would like to have on my context menus. Any information on how to create that functionality into
a context menu, or future article on that, would be great too!
Again, sorry if my questions are abit off-topic or inappropriate here.
Thank, you
AnswerRe: How to Add Separators or Submenus to ... PinsussMike Dunn2-Jul-00 18:03 
GeneralMFCClean - Why is great PinsussLeon6-Jun-00 18:03 
GeneralBUGFIX: Not registering on NT/2K PinsussMike Dunn5-Jun-00 21:09 
Generalfiles with similar extensions PinsussJuan José Rodríguez5-Mar-00 18:03 
GeneralRe: files with similar extensions PinsussMike Dunn5-Mar-00 20:07 
GeneralRe: files with similar extensions PinsussMatthew Ellis6-Mar-00 3:42 
GeneralRe: files with similar extensions PinsussAlvaro Mendez9-Jun-00 9:32 
GeneralRe: files with similar extensions PinmemberUniwares12-Jul-01 4:22 
GeneralRe: files with similar extensions PinmemberAndreas Saurwein16-Jul-01 22:37 
GeneralRe: files with similar extensions PinmemberSardaukar30-Oct-01 6:45 
GeneralNo source for the DLL PinsussMichael Walz4-Mar-00 1:59 
GeneralPardon? PinsussMike Dunn4-Mar-00 12:29 
Generalsimilar program PinsussDarren Schroeder2-Mar-00 8:30 
GeneralRe: similar program PinsussChris Maunder2-Mar-00 16:48 
GeneralRe: similar program PinsussMike Dunn2-Mar-00 19:04 
GeneralRe: similar program PinsussTodd Wilson9-Jun-00 6:18 
GeneralRe: similar program PinsussPaul Dixon5-Mar-00 23:03 
GeneralRe: similar program PinsussChris Maunder9-Jun-00 4:13 
QuestionHow do you register the DLL? Pinsuss2-Mar-00 6:37 
AnswerRe: How do you register the DLL? PinsussGerry Shaw2-Mar-00 7:42 
GeneralRe: How do you register the DLL? Pinsuss2-Mar-00 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150326.1 | Last Updated 25 Dec 2002
Article Copyright 2000 by Michael Dunn
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid