Ask Leo! by Leo A. Notenboom

Where did all these other temporary files come from?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » Windows » Windows Performance

Summary: Many programs will scatter temporary files throughout your hard disk. It's usually accidental, but cleaning up temporary files becomes a little complex.

About once a week I go into Internet Options and delete temp files, cookies and history. I also run the disk cleanup utility. I use CCleaner and run it in default mode to clean out system temp files, memory dumps, file fragments, etc. And finally, I open up a command prompt (as you suggested in a previous article) and run cd /d %TMP% and rd /s . to really clean things out.

Then today I read an article that said to use the XP search function and search for *.tmp, *.chk, ~*.* - the article said be prepared to be amazed at how many temp files it will find.

I ran the search and it found 116 files taking up more than 1.2GB of space on my computer!! My questions should be obvious: with all the other cleaning tools I've used, where the @#$%&! did these come from, why haven't they been previously deleted? Some go back more than a year ago when I had to reformat/reinstall XP!

You know, I'd forgotten about all those files when I wrote that prior article about deleting files in the Windows temporary folder.

In a way, I'm somewhat surprised that the Disk Cleanup Utility didn't at least make an attempt. But then again, I also understand why it couldn't possibly get it right 100% of the time.

These files show up and accumulate for various reasons, but the two most common are:

  • programs that misbehave and don't put temporary files where they should, and then don't clean up after themselves

  • programs that crash, thus losing track of their temporary files

Let's take one concrete example: Microsoft Word.

When you open a document in Word, if you then examine the folder containing that document, you'll also find an additional, hidden file:

Word Document listed in Explorer, showing temp file along side

In this example you can see I've opened AskLeoExample.doc in Microsoft Word, and it then also created ~$kLeoExample.doc. That later file is a temporary file used by Microsoft Word while I work on the document. It's automatically removed when I exit Microsoft Word normally.

But, note my use of the word "normally". If, for some reason, Word or my computer crashes that file remains. In some cases if you open the same original document in Word, it'll notice that the temporary file is present, and actually use it for the "auto recovery" feature. Sometimes it won't. And if for some reason you never open that exact same document in that exact same place, there's no one to come along and delete the temporary file.

Ever.

And so they accumulate, along with other temporary files from programs that crash, or programs that simply misbehave and leave things behind.

As a side note, you might wonder why Word places the temporary file in the same directory as the original without using the Windows Temporary folder. It's a valid technique that can avoid a file copy operation since the Windows temporary folder could be on another drive. If placed in the same folder, the temporary file can simply be renamed if it becomes the new "official" copy of the file. If the temporary file is on another drive it must be copied to the proper location.

So ".tmp" files are typically temporary files as their name implies. Files beginning with tilde (~) are often Microsoft Office temporary files. And ".chk" files are files representing recovered disk space or possibly data produced by CHKDSK.

Usually. Typically. Most of the time.

And that's why the Disk Cleanup utility can't actually just delete these files. There's actually no guarantee that the files are expendable. For all we know, a program could be storing incredibly valuable information in ".tmp" files. It's silly, downright stupid actually, to do so, but there's nothing that says they couldn't.

Hence Disk Cleanup can't take that chance.

But we can.

This is one of those cases where the Windows Search for Files or Folders is quite useful. Firing it up and searching my hard drive for *.tmp results in this:

Searching for *.tmp

As you can see, even on my machine where I do tend to keep things relatively clean, there are lots of ".tmp" files left around. This screen shot was taken during the scan - when it finally completed there were 31 files, but one of which was half a gigabyte in size. CTRL-A to select 'em all, and SHIFT-Del to permanently delete them, and I had that disk space back.

I repeated the process for ~* found another 28 files, but only around 26k of space, and *.chk still another 9 files and 34k.

The real question you should be asking is: is it safe? Since Disk Cleanup isn't taking the risk, should I?

99 times out of 100 it'll be just fine. An appropriate compromise before deleting any file you're not sure of is simply to either rename it, move it to a different location, or heck, burn it to CD. That way if you find later that you needed the file you can restore it.

But in the scenario I just walk through in writing this article and cleaning up my machine I didn't bother.

Related:

Helpful? Get new articles weekly by email in my FREE newsletter!

Your Name:
Your Email:


Why Subscribe?

Article C3226 - December 3, 2007

Recent Comments
6 Comments

Leo: I have just tried cleaning out temp files using *.tmp The search surprised me finding so many temp files. However, when I tried to delete them using clt-A and shift-delete I got the message: Error Deleting Files or Folder
Cannot delete file: Cannot read from the source file or disk. So where have I gong wrong? Cheers

Posted by: Ron Barker at December 8, 2007 2:00 AM

Sometimes, you will not be allowed to delete a file if a program is using it at the time.

Posted by: Bill at December 8, 2007 4:30 AM

Thanks for that. I can delete the temp file one by one. There are over a 1000. I cannot delete the the temp files all at once or even in small blocks. I am not sure what 'if a programme is using the file' means because all programmes are closed down other than explorer. Cheers

Posted by: Ron Barker at December 8, 2007 5:57 AM

I read the article but I still do not understand why when you delete something it doesn't stay deleted. When you want to save something you create a file name & save the E-mail. When you open the file it says it's empty. I'm 67 and it is very hard to understand

Posted by: Raymond Hughes at December 8, 2007 8:56 PM

I have Microsoft Word & Excel I Have A Problem Is When i Open Microsoft He Create Word.tmp But Not Remove Automaticly

Posted by: Kuldeep Shrimali at March 21, 2009 12:34 AM

Word 2007 is not auto deleting the temp files on a few machines.

The program or computer is not crashing. The file is working correctly. We have no problem deleting those temp files once we have closed out of the file.

If another user works on the same file they don't have the problem. It has to be machine related.

Any idea?

Posted by: Barb at September 9, 2009 6:33 PM

Post a comment on "Where did all these other temporary files come from?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

  • Read the article at the top of this page. If your comment shows you didn't, it'll be deleted and ignored.

  • Comment only on this article. Use the Google search box at the top of the page if you have a question about something else.

  • Don't include personal information in the comment. No email addresses. No phone numbers. No physical addresses.

  • Don't spam. Excessive links to unrelated sites within a comment or across multiple comments will cause all such comments to be removed.

  • Don't ask me to recover lost passwords or hacked accounts. I can't, and those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...


Question? Ask Leo!