"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,820 tips!

Windows XP and DOS

Defragment Just One File or Directory

SUMMARY: Only defragment a particular file or directory that you frequently access.

If you frequently modify a particular file or directory on your Windows XP system, that file or directory may become fragmented more quickly than other files / directories on your hard drive. If so, while you can defragment the entire drive via a batch file, it may prove useful and quicker to just target the particular file / directory for defragmentation if it is changed often.

Defragmenting a single file or directory can be accomplished via the contig command, available from the Sysinternals site, part of Microsoft Technet.

Simply download the zip file contig.zip, unzip the contained executable to your main Windows directory, and you can defragment an often-changed file via the command prompt:

contig FILENAME

where FILENAME is the path to a file you wish to defragment.

Contig will display a copyright statement and then a summary, such as the following if the file does not need to be defragmented:

Summary:
Number of files processed : 1
Number of files defragmented: 0
All files were either already defragmented or unable to be defragmented.


Contig supports the following options:

-q

This runs contig in silent mode, only printing the copyright and summary information. If you want contig to run completely quiet, issue the following command:

contig -q FILENAME > nul

-v

This displays additional information about the defragmentation process.

-a

This only analyzes a file to see its fragmentation status and will not actually perform defragmentation.

-s

This recurses subdirectories, allowing you to defragment or analyze all files and subfolders inside a folder.

For example, to recursively defragment all files inside the directory c:\data and display added information about the defragmentation process, issue this command:

contig -v -s c:\data\

* Download Sysinternals Contig

Return to the Windows XP and DOS page.

Print this tip


Get the Newsletter

blog comments powered by Disqus

Thanks For Sharing!



Newest Tips:

Microsoft Word 2010
W0rds w8th Numbers Pass the S0ellchecker!
Google Gmail
Automatically Archive a Conversation you Respond to
Digital Photography
[MODIFIED] Did Someone Get in the Way While Taking a Photo?
Google Chrome
View Kittens and Pandas Everywhere!

Follow Us!

About MalekTips and the Author

The MalekTips website was created in 1998 by Andrew Malek of Envision Programming. The page's goal is to freely disperse computer-related tips, hints, and informative articles. Tips are organized to be easy to find, and are presented clearly, in easy-to-understand language. MalekTips also provides information and links to public-domain, open source, freeware, shareware, and commercial software available for download. < more >