Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

Defrag all Hard drives at once in Windows

Martin Brinkmann
Jul 7, 2007
Updated • May 30, 2018
Windows
|
7

The defragmentation tool that ships with Windows is pretty basic and does not offer features that you may need to make use of. I'm not talking about functionality in regards to defragmenting the hard drive to speed up operations, but about basic functionality that you may need.

One example is that there is no option to defrag multiple partitions or drive at once. If you want to defragment multiple drives, you need to select the option after the defragmention of a drive completes. That's not that great of an option considering that you need to be present to run those commands and that you can't just keep the defrag running during night or at times when the computer is idle.

There is however an option that you have that you can make use of to defragment all of your partitions and drives at once. You can use a little batch file to do that which allows you to run it whenever you need to and it takes care of all drives you add to the batch file.

Defrag all Hard drives at once in Windows

defrag all drives

There are a couple of things you need to know though. You need to run the script with elevated rights which you can do easily by right-clicking on it and selecting to run the file as administrator. Just make sure you do so and everything else should be automatic from that moment on.

I have four partitions with the drive letters C:, D:, E: and F: which means that the batch script will look like the following:

@echo off
defrag.exe c: -f
defrag.exe d: -f
defrag.exe e: -f
defrag.exe f: -f

You need to edit the list to match the drives that you want to defragment using the batch file. Note that you don't need to include Solid State Drives in the list of drives. Also note, that Windows 10 runs automatic drive optimizations regularly by default.

To create the batch file do the following. Create a plain text document and copy & paste the commands you see above to it.

You may need to modify the drive letters and maybe even add or remove lines so that all of your drives are covered. Change the file extension to bat afterward and make sure you do not have a .txt extension anymore.

Run the file by right-clicking on it and selecting the "run as administrator" option from the context menu.

Summary
Defrag all Hard drives at once in Windows
Article Name
Defrag all Hard drives at once in Windows
Description
Find out how to defragment all hard drives of a computer system running Microosft's Windows operating system at once using a simple batch file.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. mosey said on July 12, 2007 at 10:03 am
    Reply

    Martin: Thanks! :D I’ll give it a go!

  2. Martin said on July 11, 2007 at 9:18 am
    Reply

    mosey just create a file called defrag.bat and double-click it to execute.

  3. mosey said on July 11, 2007 at 3:17 am
    Reply

    Sorry, newbie here – the line above goes into something called ‘batchfile.exe’ or something?

    Thanks :D

  4. gnome said on July 8, 2007 at 4:56 pm
    Reply

    Yp, scandefrag it is then! Nice one Khu

  5. Captain Picard said on July 8, 2007 at 2:56 pm
    Reply

    This is a good tip; not many people know that you can defrag multiple drives in windows. But even so, the windows defraggers take way too much time to defrag, and often they dont do a good job. (eg. they dont defrag the $MFT AFAIK). The Vista defragger also seems to be crippled wrt available options and progress display.

    If you go out of the freeware arena, there are some good defraggers like Diskeeper Pro that make defragging easy and fast. DK gives better options for defragging single or multiple drives, and the defrags are also much faster compared to windows. But Diskeeper’s trump card is the autodefrag mode…set it and forget about manually defragging from that point on. Might sound like hype, but actually works really well.

  6. khu said on July 8, 2007 at 1:16 pm
    Reply

    Or you can just use ScanDefrag:

    http://www.blueorbsoft.com/scandefrag/

  7. sspace said on July 8, 2007 at 2:38 am
    Reply

    In Vista you can defrag all volumes with the command:
    “defrag -c” from an administrator command prompt .

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.