Thursday, 2 May 2013

How to delete index.dat browsing history

Index.dat files, as maintained by MS-IE (see grow ever larger, slowing things down, and are a privacy threat. If you're leaving a job and have been browsing privately in your lunchtimes (with permission of course) perhaps you'd like to remove all the data before you leave - presuming you're trusted enough to tidy up your things and weren't working in the kind of place that shows you straight to the door after giving you the bad news (with your belongings boxed up and sent on afterwards!). Thankfully I've always been allowed the chance to clean up after myself, so far.

Having just Googled for delete index.dat I'm surprised so many sites came up making a meal of it.

If you were on a 'roaming profile' setup, it's tricky and I ran out of time to experiment. Sorry. But if not, the main difficulty is that the files are in use if you try to delete them.

It's not too hard to find the files - open a command window, head up to root \  and try :
C:\>dir index.dat /s /ahs /b

If you want full control over which to delete, create a batch as follows :
C:\>dir index.dat /s /ahs /b >idat.txt

Open idat.txt in a text editor, and add " quotes around each path+filename by speedy use of the back-tick ` key, and [down] and [End] etc.... then Search-and-Replace the ` with "
... then seach and replace
del c:\

Ctrl-a to mark the whole lot, and ctrl-c to copy to clipboard.
Search and replace
del c:\
attrib -s -h -a -r c:\

Go to a new line at the end, and paste in the saved delete lines.

You now have a batch file to change all the index.dat attributes and delete them, with two blocks of safely quoted filenames (in case of spaces in the paths) preceeded by attrib and del commands.

Save and rename idat.txt to idat.bat

Releasing the grip on the files - kill Explorer

Keep the command window open while killing explorer - this will remove the "file in use" problem you would have had when trying to delete the dat files.

To do this (Windows 7), click the Windows Start button, then [Left Shift]+[Ctrl]+[Right Click] the area around the Shut Down button. A context menu should appear with "Exit Explorer" as an option. Use it, and the Windows desktop will vanish execpt for the wallpaper and the one command window you still have open.

On earlier versions of Windows, you may have to select the Shut Down dialogue, then Click the Cancel button with [Left Shift]+[Ctrl]+[Alt] all held. It will happen immediately with no chance to back out - no "Exit Explorer" option this way.

With Explorer out of the way, the files you want to remove can now be disposed of. Run the batch file of attrib and del commands, or if you want to do it more quickly, this command will take care of the Hidden, System & Readonly attributes of all index.dat files :

C:\>for /r %x in (index.dat*) do @attrib  -s -h -a -r "%x"

You then just up arrow and edit the command to delete instead of changing the attribs :
C:\>for /r %x in (index.dat*) do @del "%x"

Now simply Ctrl-Alt-Delete to log off and get back to normal. When you load up MS-IE again, the index files with be recreated, hopefully smaller than they were, default sizes, containing no private data any more.

It's almost as easy as booting from a Linux USB stick, mounting the NTFS drive and deleting files from there.
Now, resolve to use Firefox instead, in future!

No comments:

Post a Comment