computer help index
 
 
Search:
"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,240 tips!

Windows XP and DOS

Defragment Drives in DOS or a Batch File

SUMMARY: As an alternative to Windows XP's GUI-based Defrag application, use DOS's defrag command from the command prompt or a batch file.
 
Unless you use a third-party defragment utility, chances are that if you defragment your hard disks you use the built-in Windows XP Defrag application. This GUI-based tool visually represents defragmented, continuous, and unmovable files, as well as free hard drive space.


Windows XP Defrag application

While the Defrag application runs you can see the progress onscreen, and you can pause or stop the process if needed.

In some cases, however, the GUI interface may not be desired. You may want the computer to concentrate on the actual defragmentation process, not updating a colorful display. Or, perhaps you are developing a startup script or other batch file to warn about a drive's status. To do so, use the DOS defrag command, followed by the drive letter or mount point that you wish to defragment.

To defragment the C volume:

defrag c:

This displayed the following information on one computer before starting the actual process:

Analysis Report
112 GB Total, 67.44 GB (60%) Free, 14% Fragmented (28% file fragmentation)


To stop the process, just press CONTROL+C.

To display more output during the process, add the -v parameter. For example, the following extra analysis was displayed:

defrag c: -v

Analysis Report

Volume size = 112 GB
Cluster size = 4 KB
Used space = 44.10 GB
Free space = 67.44 GB
Percent free space = 60 %

Volume fragmentation
Total fragmentation = 14 %
File fragmentation = 28 %
Free space fragmentation = 0 %

File fragmentation
Total files = 87,750
Average file size = 683 KB
Total fragmented files = 10,709
Total excess fragments = 180,514
Average fragments per file = 3.05

Pagefile fragmentation
Pagefile size = 2.00 GB
Total fragments = 1

Folder fragmentation
Total folders = 7,528
Fragmented folders = 319
Excess folder fragments = 1,513

Master File Table (MFT) fragmentation
Total MFT size = 94 MB
MFT record count = 95,700
Percent MFT in use = 99
Total MFT fragments = 2


To print just the analysis report and not actually defragment the drive, use the -a parameter. You can combine this with the -v parameter to display a more detailed report as shown above.

defrag c: -a -v

The below option is not recommended but listed for informational purposes only.

Microsoft recommends that to safely defragment a hard disk there should be at least 15% room free on the drive. You can bypass this safety net by adding the -f parameter.

 

 
Add: Del.icio.us | Digg | Furl | My Yahoo!
 
Discuss This Tip

Print This Tip

Get E-Mail When New Tips are Online

Return to the Windows XP and DOS page.

RSS Feeds - Subscribe!
 

You want the latest tech tips and tricks in your e-mail Inbox - FREE? Type your e-mail address below and click 'Subscribe'.
 



( sample / details ) ( opt-out instructions )
 


 Free Offer! - Subscribe to the MalekTips computer help list and be one of the first to get new computer tips, articles, and download links! ( privacy policy )  ( opt-out instructions )
This page and its contents are copyright
©1997 - 2008 Envision Programming. ( copyright/disclaimer )

Home | Free Computer Help Newsletter! | Windows | Web Development | DOS and Batch Files | Removing Spyware
Digital Camera and Photography | Computer and Internet | Software | Microsoft Word
Computer Articles | About | Contribute a Tip | Link To Us! | Computer and Technology Links
RSS Feeds |  Contact Us | Advertising | Privacy Policy | Computer Help Forums