Defragment specific files or folders with Sysinternals Contig

November 19, 2012 – 08:53 by in Tips Print Share No Comment

If you’d like to optimize the performance of a game (or any other disk-intensive application) then defragmenting its key files before you start can sometimes help – but of course that’s not usually a very practical idea. Most defrag tools will want to process your entire partition, which could take a while, and may not touch the files you’re really interested in anyway (defraggers often leave a few fragmented files behind when they’re done).

Fortunately there’s a simple alternative in the shape of Sysinternals Contig, a tiny command-line tool which defrags only the files you specify, and doesn’t “forget” any of them. Give the program a file, and it will be defragmented.

At its most basic, all you have to do is point Contig at a file (or set of files) and watch as it analyzes and defrags them, where necessary. Entering commands like this, for instance:

Contig large.exe
Contig c:\important\*.*
Contig c:\folder\*.dll

Contig provides some useful command line switches to control exactly what the program does

But there are some useful command line switches, too. The program can analyze and report on file fragmentation, for instance. Or recurse subdirectories, allowing you to defrag all the files in a folder tree. While it can even analyze and defragment key NTFS metadata, such as $Mft or $Boot.

And the program uses the standard Windows defrag API, so you can be reasonably sure that it’s not going to corrupt your hard drive, even if you turn your system off while it’s running. (Although as with all defrag programs, we wouldn’t recommend you use it unless your system is fully backed up.)

Contig also has its issues, of course. And our main one was performance. We set the program to work on a massive, heavily-fragmented disk image, and it took an age to complete. In some circumstances you might find it’s quicker to allow a good GUI-based defragger to process your hard drive, rather than give Contig too much work to do.

If you’re an experienced PC user who would like to take more control over the defrag process, though, Contig just might be useful. Not least because it comes in the form of a tiny (204KB) portable executable, ready to run on just about any Windows system, whenever you like.

Comments are closed.