Click here to Skip to main content
15,903,012 members
Articles / Programming Languages / C++

A Utility to Clean Up Compiler Temp Files

Rate me:
Please Sign up or sign in to vote.
4.92/5 (41 votes)
24 Dec 2002 369.5K   3.6K   97   94
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 "*.*" ;) 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

Written By
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

QuestionThe menu don't show on Windows 10 context menu Pin
mbncvbut24-Feb-21 22:51
mbncvbut24-Feb-21 22:51 
AnswerRe: The menu don't show on Windows 10 context menu Pin
mbncvbut14-Dec-22 21:44
mbncvbut14-Dec-22 21:44 
Generalthis is still a good tool Pin
Southmountain3-Feb-20 14:29
Southmountain3-Feb-20 14:29 
GeneralFinding a directory Pin
toutarrive3416-Sep-09 5:00
toutarrive3416-Sep-09 5:00 
Generalfix for *.resx and other long extensions Pin
rockonedge16-Sep-08 23:11
rockonedge16-Sep-08 23:11 
GeneralIssue: C# *.resx files mistakenly deleted Pin
Jeffrey Walton15-Jul-08 3:58
Jeffrey Walton15-Jul-08 3:58 
GeneralExcellent, except for one minor problem Pin
frwa7-Apr-08 10:33
frwa7-Apr-08 10:33 
GeneralVista / VS2005 Pin
Kevin Gutteridge30-Jul-07 4:07
Kevin Gutteridge30-Jul-07 4:07 
GeneralKudos and Small Suggestion Pin
Jeffrey Walton8-Jun-07 9:33
Jeffrey Walton8-Jun-07 9:33 
GeneralRe: Kudos and Small Suggestion Pin
Michael Dunn9-Jun-07 19:20
sitebuilderMichael Dunn9-Jun-07 19:20 
GeneralThe .resx registry fix doesn't work on my system Pin
CPallini1-Apr-07 23:03
mveCPallini1-Apr-07 23:03 
GeneralRe: The .resx registry fix doesn't work on my system Pin
Michael Dunn2-Apr-07 20:14
sitebuilderMichael Dunn2-Apr-07 20:14 
GeneralI think you should give more emphasis to.. Pin
CPallini1-Apr-07 22:51
mveCPallini1-Apr-07 22:51 
GeneralAdvertising... Pin
simonchen.net4-Jan-07 4:57
simonchen.net4-Jan-07 4:57 
QuestionHow To Register a dll ? Pin
murtaza dhari4-Oct-06 8:34
murtaza dhari4-Oct-06 8:34 
AnswerRe: How To Register a dll ? Pin
Michael Dunn4-Oct-06 8:52
sitebuilderMichael Dunn4-Oct-06 8:52 
GeneralExcellent Tool Pin
Bassam Abdul-Baki25-Mar-05 4:06
professionalBassam Abdul-Baki25-Mar-05 4:06 
GeneralRe: Excellent Tool Pin
Michael Dunn25-Mar-05 6:16
sitebuilderMichael Dunn25-Mar-05 6:16 
GeneralRe: Excellent Tool Pin
Bassam Abdul-Baki25-Mar-05 6:50
professionalBassam Abdul-Baki25-Mar-05 6:50 
GeneralRe: Excellent Tool Pin
Michael Dunn25-Mar-05 7:07
sitebuilderMichael Dunn25-Mar-05 7:07 
GeneralRe: Excellent Tool Pin
Bassam Abdul-Baki25-Mar-05 7:25
professionalBassam Abdul-Baki25-Mar-05 7:25 
GeneralRe: Excellent Tool Pin
Bassam Abdul-Baki25-Mar-05 7:31
professionalBassam Abdul-Baki25-Mar-05 7:31 
GeneralAn suggestion: Don NOT use Win95TruncatedExtensions technique Pin
Behzad Ebrahimi25-Nov-04 4:15
Behzad Ebrahimi25-Nov-04 4:15 
GeneralAccessing Medias with ShFileOperation Pin
Anonymous17-Aug-03 3:06
Anonymous17-Aug-03 3:06 
GeneralRe: Accessing Medias with ShFileOperation Pin
Michael Dunn17-Aug-03 7:38
sitebuilderMichael Dunn17-Aug-03 7:38 

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

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