Quantcast
PCWorld.com is upgrading some back-end systems. Some site features, such as user registration, may be temporarily unavailable.

Blogs

    Windows Tips

  • Living with Windows is a whole lot easier with the tips, tools, and techniques from Contributing Editor Scott Dunn's bottomless bag of tricks.
  • Subscribe to this blog

Windows Tips: The Fast, Simple Way to Defragment Your Disks

Scott Dunn

You say you'd defragment your hard drive if only doing so weren't so time-consuming? Well, have I got a batch file for you. (Before you defragment, you should scan your disk for errors. For tips on automating your disk scans in Windows XP, read my September 2003 column at Check Your Disks for Errors, With a Single Click.)

First, the manual defragging approach: Click Start, Programs (or All Programs), Accessories, System Tools, Disk Defragmenter, Defragment (see Figure 1). You can defrag only one drive at a time this way, but Windows' defragging tool shows the drive's fragmentation graphically and lists all your drives, so you can defragment one after another without a lot of clicking through dialog boxes.

It's always best to defrag a disk when it's not in use. To set up Windows to defrag a drive automatically at such a time, start by opening Notepad or another text editor, and type defrag.exe followed by a space, the drive letter, and a colon.

A drive that's low on disk space may balk at defragging, so type a space and -f to force Windows to defrag it anyway. Windows can also generate a report on the defrag when it's done: Type a space and -v to get all the details available. Next, enter > (a greater-than symbol), followed by the path to a text file that will log the results. (Note: If a text file of that name in that location already exists, it will get overwritten.) Be sure to place quotation marks around your path if it contains any spaces, or if It uses long file or folder names.

So after all that, your command line might look like this: defrag.exe c: -f -v >"e:\doc\defrag report.txt" (your path and file name may differ, of course). Finally, press <Enter>.

If you want to defrag more than one drive, create a command line for each one, changing the drive letter and the file name and path as necessary (see Figure 2). When you're done, choose File, Save, and save the file to a convenient location. Make sure to use the .bat or .cmd file extension.

Now any time you want to defragment the drives, just double-click the .bat or .cmd file you created. (Or drag the file's icon from Windows Explorer or any folder window and drop it onto your Start menu to create a shortcut there.)

Finally, Windows' Scheduled Tasks utility lets you defragment automatically at the time of your choice. To open this tool, click Start, Programs (or All Programs), Accessories, System Tools, Scheduled Tasks. Double-click the Add Scheduled Task icon, and click Next. When prompted for the program to run, click Browse and locate your batch file. Select it and click Open. Follow the remaining prompts to make the disk defragmenting occur whenever you want (see Figure 3).

Scheduled Tasks requires that you log on using a password-protected account; you supply your Windows log-in password as part of the scheduling process. For a way to work around this, see Lincoln Spector's Answer Line column from January 2003, Synchronize Important Folders on Two Computers.

  • Recommend this story?
  • 0 Yes
    0 No

"Windows Tips: The Fast, Simple Way to Defragment Your Disks" Comments

Featured APC Accessories

  • APC Back-UPS ES Safeguards your equipment from damaging surges and spikes that travel along your utility & data lines.
  • APC SurgeArrest Performance Highest level of protection for your professional computers, electronics and connected devices, as well as provides surge protection.

Focus on Personal Productivitysponsored by Microsoft

  • Personal Finance 2.0 These free and fee-based Web services not only aggregate data from your online bank accounts, they give you tools for managing your money.
  • High-Tech Travel Tips Plenty of stories provide advice for elite mobile professionals. But what about you, the unproductive traveler?

People who read this also read:

All PC World Blogs

  • Lenovo Laptop Showcase Find out how Lenovo IdeaPads and Thinkpads balance performance and portability. Visit the Lenovo Resource Center for more info...

Sponsored Links