PC Magazine -- April 9, 1996

Deleting Temporary Files

Whenever Windows crashes, one result is the temporary files left scattered all over my hard disk. But I've added a line to the end of my AUTOEXEC.BAT file that eases the chore of cleaning up the disk: DIR *.TMP /S. Now every time I boot up, I get a list of every .TMP file on my hard disk, and I can then delete them.

The first time I used this command, there were so many .TMP files in so many directories that I tried to find a global delete command to delete all .TMP files automatically. I never did find one, but with Windows' File Manager I was able to search for and delete them more easily.

I crash Windows fairly often and have noticed that the .TMP files tend to end up in the directory of the program I was using, such as Microsoft FoxPro for Windows. This surprised me, since my AUTOEXEC.BAT file includes the line SET TEMP=C:\TEMP. I would have expected this to be the most likely place to find the stray files.

    Jeff Wyatt, Abilene, Texas

PC MAGAZINE: File Manager's Search function does indeed make it easy to locate and operate on files matching a particular template, wherever they may reside on your disk. But you're making a big mistake by deleting .TMP files that way! While Windows is running, .TMP files are sacrosanct; deleting them can cause the Windows crashes that you say occur "fairly often." The only safe way to clean up orphaned .TMP files is to do it completely outside of Windows.

Here's one technique you can use to locate and delete all .TMP files. In the root directory of the C: drive, issue the command

    DIR *.TMP /A /B /S > DELTEMPS.BAT

You will get a listing of the complete pathname of every .TMP file, even those with attributes that would normally hide them from view. Load the DELTEMPS.BAT file into DOS's EDIT program and select Change from the Search menu. Search for C:\ and replace it with DELTREE /Y C:\ . Save the file, exit EDIT, and run DELTEMPS.BAT. This will wipe every .TMP file from your disk. The reason to use DELTREE instead of just DEL is that it will delete even files with read-only, hidden, or system attributes.

As for why the .TMP files are scattered instead of residing in the directory identified by your TEMP environment variable, that's because individual applications are free to create temporary files anywhere they want. There's nothing that forces them to use the official TEMP directory.

--Neil J. Rubenking

Imagemap: Load Images for selection
Home ZDNet
Advertising Index

Copyright (c) 1996 Ziff-Davis Publishing Company