Right-button Command to Remove Extra VS Files


This article was contributed by Ed.

Environment: NT, will work on 9x with modification.

You'll notice that in most of the .zip files you download with code from sites like codeguru include a .ncb file.

This is where Visual Studio stores its state information; stuff like what files you have open. Most of the time, the rest of the world isn't interested! And most of the time, the .zip files are up to 50% smaller without them!

Rather than having to remember to go through your project directory and clean it manually for release, why not right-click the folder and make your computer do the hard work?

This is a self-extracting batch file that adds two commands to the right-click menu for folders in the Windows shell. It's been written and tested under Windows 2000. You'll need to run it as Administrator. It creates (program files)\folder-clean, puts in two batch files, and adds the necessary registry keys to enable it.

The two commands are:

For release leave exe

This will recursively search the directory and delete all intermediate files ending with these extensions:

    (unnecessary Visual Studio files)

  • aps
  • clw
  • ncb
  • opt
  • plg

    (intermediate files)

  • obj
  • pch
  • exp
  • sbr
  • bsc
  • ilk
  • lib
  • pdb
  • res
  • idb

    (executable and DLL files are not removed)

For release clean

This will recursively search the directory and delete all intermediate and executable files. This will remove files ending with the extensions given above, plus these extensions:

    (executable and DLL files)

  • exe
  • dll
Be aware that when it runs, a DOS box will flash up. This is normal.

Here is the source code of the installer/self-extractor:

@echo off
rem only tested on NT 5
set instdir=%ProgramFiles%\folder-clean

set regfile=%TEMP%\fclean.reg
set reginstdir=%instdir:\=\\%

echo Windows Registry Editor Version 5.00 >%regfile%
echo [HKEY_CLASSES_ROOT\Directory\shell\For release clean\command] 
>>%regfile%
echo @="\"%reginstdir%\\clnrmexe.bat\" \"%%1\"" >>%regfile%
echo [HKEY_CLASSES_ROOT\Directory\shell\For release leave exe\command] 
>>%regfile%
echo @="\"%reginstdir%\\cleanrel.bat\" \"%%1\"" >>%regfile%

set filename1=%TEMP%\cleanrel.bat
set filename2=%TEMP%\clnrmexe.bat
rem vstudio files
echo del /s %%1\*.aps >%filename1%
echo del /s %%1\*.clw >>%filename1%
echo del /s %%1\*.ncb >>%filename1%
echo del /s %%1\*.opt >>%filename1%
echo del /s %%1\*.plg >>%filename1%
rem intermediate files
echo del /s %%1\*.obj >>%filename1%
echo del /s %%1\*.pch >>%filename1%
echo del /s %%1\*.exp >>%filename1%
echo del /s %%1\*.sbr >>%filename1%
echo del /s %%1\*.bsc >>%filename1%
echo del /s %%1\*.ilk >>%filename1%
echo del /s %%1\*.lib >>%filename1%
echo del /s %%1\*.pdb >>%filename1%
echo del /s %%1\*.res >>%filename1%
echo del /s %%1\*.idb >>%filename1%

rem exe etc
copy %filename1% %filename2%
echo del /s %%1\*.exe >>%filename2%
echo del /s %%1\*.dll >>%filename2%
echo del /s %%1\*.hlp >>%filename2%

mkdir "%instdir%"
copy %filename1% "%instdir%"
copy %filename2% "%instdir%"
%regfile%

del %filename1%
del %filename2%
del %regfile%

Downloads

Download source - 1.45 Kb

CODEGURU CAUTION: This utility DELETES files



Comments

  • Helped me with an Explorer menu addition

    Posted by Legacy on 10/19/2001 12:00am

    Originally posted by: Rich Fearn

    While on a work placement last year a colleague's computer had a useful addition to the menu you get when right-clicking a directory in Explorer - "Command Prompt here", which opens a command prompt with the current working directory set to the one you right-clicked on!

    I have no idea where this useful feature came from, and although not directly related to this article, your code did help me figure out how to set the "Command Prompt here" up manually, using the Registry Editor:

    1. Open the Registry Editor (Start -> Run "regedit")
    2. Find the "HKEY_CLASSES_ROOT\Directory\shell" key
    3. Create a new key, named "CPHere"
    4. Edit the "(Default)" value of the "CPHere" key to "Command Prompt &here"
    5. Create a new key inside "CPHere", named "command"
    6. Edit the "(Default)" value of the "command" key to "C:\WINDOWS\command.com /Kcd %1" (without the quotes though!)

    I find it useful anyway!

    Cheers

    Rich

    Reply
  • very good

    Posted by Legacy on 10/17/2001 12:00am

    Originally posted by: tiger

    thanks for this tiny code and the nice idea.

    Reply
  • Better util exists

    Posted by Legacy on 10/12/2001 12:00am

    Originally posted by: Bill C.

    http://www.codeproject.com/tips/dirclean.asp

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: January 28, 2015 @ 11:00 a.m. ET / 8:00 a.m. PT Check out this upcoming live webcast and join Jeff Sloyer, IBM Developer Evangelist and Master Inventor, for a tutorial for building cloud-based applications. Using IBM's platform as a service, Bluemix, Jeff will show you how to architect and assemble cloud-based applications built for cloud scale. Leveraging the power of microservices, developers can quickly translate monolithic applications to a cloud-based microarchitecture. This hour-long …

  • Live Event Date: February 11, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT New computing platforms, expanding information environments, recurrent security breaches and evolving regulatory frameworks are factors that security executives must contend with and address when developing their security strategy. In response to these dynamics, security executives are seeking stronger, more nimble and more pervasive security technologies to help protect business-critical information from unauthorized disclosure, loss or …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date