|
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. |