How to Perfectly Defragment Your Hard Disks with MyDefrag

Mydefrag Your Way Featured

The primary parts in hard disk drives are their rotating platters and the heads that read and write data on them. The outer part of those disc-shaped platters, thanks to what Physics teaches us, have faster linear acceleration. Also, there’s a perceived performance cost when data is spread all over their surface.

MyDefrag might be semi-extinct, but it remains the only program of its kind that can optimize your hard disk precisely the way you want it. Like all defragmenters, it reorganizes all parts of your files, packing them together, fixing the low performance when spread all over the surface issue. It also allows you to set up zones, placing your most important files to the faster, outer region of the HDD’s surface. You just have to tell it what goes where through a simple script.

Locate, download and install MyDefrag

Unfortunately, MyDefrag is unsupported nowadays, and its official site is dead. You can still find it, though, at popular software hosting sites, like FileHippo and MajorGeeks.

Mydefrag Your Way Installation

Download and install the last ever version of the program, MyDefrag 4.3.1. Accept all defaults during the installation and make sure “Select and activate the MyDefrag ScreenSaver” is deselected.

Create a new script

You don’t control how MyDefrag operates through a graphical interface or command-line options – it’s done with simple scripts. Locate the sub-folder scripts, that exists for this purpose in its installation directory.

Mydefrag Your Way New Script

Right-click in this directory and create a new, blank TXT file. Give it any name you please, but change its extension to “MyD,” the default for MyDefrag scripts. Then, open it in your favorite text editor.

Script intro

We’ll use the existing ones as the base for a script that optimizes a hard disk filled with games, putting the files that affect their performance more than others at the quicker parts of the disk’s surface, moving the less essential and not-frequently-accessed data to the other end.

Mydefrag Your Way Script Intro

The first part of your script should set things up as follows. Note that you should place every parameter and command on a new, individual line. Also note that we will use comments in the code – they start with “//” – to explain the more cryptic bits of our script.

Title("Title of your script")
Description("Short description of your script")
WriteLogfile("MyDefrag.log","LogHeader")
VolumeSelect
CommandlineVolumes()
VolumeActions
AppendLogfile("MyDefrag.log","LogBefore")

Set up your first zone

By splitting the HDD surface into zones, MyDefrag allows you to place specific files and folders on the parts of its surface that perform better or worse.

Mydefrag Your Way Zones

Set up zones by selecting what should go in them:

// Zone 1 - Non-important, slow files
FileSelect // Select specific files.
  !include "file_list.txt"! // Select the files defined in file_list.txt.
FileActions // What MyDefrag will do with those files.
  MoveToEndOfDisk() // Move them to slower portion of the HDD since they are the unimportant ones
  AddGap(ZoneEnd + VolumeFree * 0.1 // Add a 0.1% size gap between that zone and the next one
FileEnd // End file selection for the specific zone

Setting up more zones

MyDefrag can only pack together your files, like other defragmenters, if you don’t set up any Zones, but you’ll be missing out on the whole point of its use.

Mydefrag Your Way More Zones

We set up more zones as follows:

// Zone 2: Put directories together,  for quicker listing of the HDD's contents - same syntax as before
FileSelect 
  Directory(yes) // Define that we want to select directories, not files.
FileActions
  SortByName(Ascending) // Sort them by alphabetical order.
  AddGap(ZoneEnd + VolumeFree * 0.05)
FileEnd
 
// Zone 3: Typical, popular "game filetypes", for quicker game launching
FileSelect
Filename("_.exe")
OR Filename("_.dll")
OR Filename("_.ini")
OR Filename("_.conf")
OR Filename("_.cfg")
OR Filename("_.bat")
OR Filename("_.ico")
FileActions
  SortByName(Ascending)
  AddGap(ZoneEnd + VolumeFree * 0.1)
FileEnd
 
// Zone 4: Place the MFT and other special NTFS files right after our most important files
FileSelect
  SelectNtfsSystemFiles(yes)
FileActions
  PlaceNtfsSystemFiles(Ascending,MftSize * 0.01) // Move the selected NTFS system files and set the MFT to a %0.01 size.
  AddGap(ZoneEnd + VolumeFree * 0.01)
FileEnd
 
// Zone 5: Recently accessed files (for better performance of last games played).
FileSelect
  LastAccessEnabled(yes) and LastAccess(60 days ago,now)
FileActions
  SortByName(Ascending)
  AddGap(ZoneEnd + VolumeFree * 0.3)
FileEnd
 
// Zone 6: all other files.
FileSelect
  all
FileActions
  SortByName(Ascending)
  AddGap(ZoneEnd + VolumeFree)
FileEnd

Final script

What follows here is the whole final script. Feel free to copy and paste it into your own script, then tweak it as you wish.

Title("Make Tech Easier's Games HDD Monthly")
Description("Optimize Game HDDs by moving temp, downloading, and non-important gaming-related files and directories to its end, leaving the faster HDD space for more important stuff.")
 
// Write the header to the logfile. See the "Settings.MyD" file for the definition of the "LogHeader" string.
WriteLogfile("MyDefrag.log","LogHeader")
 
// Select and process the volumes one by one.
VolumeSelect
  CommandlineVolumes()
VolumeActions
 
// Write the "before" statistics to the logfile. See the "Settings.MyD" file for the definition of the "LogBefore" string.
  AppendLogfile("MyDefrag.log","LogBefore")
 
// Zone 1 - Place Non-important, temp and ultra-large files at the end of the disk.
  FileSelect
    !include "file_list.txt"!
  FileActions
    MoveToEndOfDisk()
    AddGap(ZoneEnd + VolumeFree * 0.1)
  FileEnd
 
// Zone 2: Directories.
  FileSelect
    Directory(yes)
  FileActions
    SortByName(Ascending)
    AddGap(ZoneEnd + VolumeFree * 0.05)
  FileEnd
 
// Zone 3: Main Game Files (for quicker game launch).
  FileSelect
    Filename("*.exe")
	OR Filename("*.dll")
	OR Filename("*.ini")
	OR Filename("*.conf")
	OR Filename("*.cfg")
	OR Filename("*.BAT")
	OR Filename("*.ico")
  FileActions
    SortByName(Ascending)
    AddGap(ZoneEnd + VolumeFree * 0.1)
  FileEnd
 
//Zone 4: Place the MFT and some other special NTFS files.
  FileSelect
    SelectNtfsSystemFiles(yes)
  FileActions
    PlaceNtfsSystemFiles(Ascending,MftSize * 0.01)
    AddGap(ZoneEnd + VolumeFree * 0.01)
  FileEnd
 
// Zone 5: Recently accessed files (for better performance of last games played).
  FileSelect
    LastAccessEnabled(yes) and LastAccess(60 days ago,now)
  FileActions
    SortByName(Ascending)
    AddGap(ZoneEnd + VolumeFree * 0.3)
  FileEnd
 
// Zone 6: all other files.
  FileSelect
    all
  FileActions
    SortByName(Ascending)
    AddGap(ZoneEnd + VolumeFree)
  FileEnd
 
// Write the "after" statistics to the logfile. See the "Settings.MyD" file for the definition of the "LogAfter" string.
  AppendLogfile("MyDefrag.log","LogAfter")
 
VolumeEnd
 
// Write the footer to the logfile. See the "Settings.MyD" file for the definition of the "LogFooter" string.
AppendLogfile("MyDefrag.log","LogFooter")

Create a low-priority file list

Remember how we told our script to take into account a low priority files list, in TXT format, before organizing our files? Now’s the time to create that file.

Mydefrag Your Way Low Priority List

Right-click in the scripts folder and create a new, blank TXT file. Name it “file_list.txt” – the same filename we used in the script itself.

Here’s a sample list you can copy and use. Change the directories and files to ones you don’t care about.

  DirectoryName("Game_I_never_play_after_installing")
    OR DirectoryName("Another_game_I_keep_but_rarely_play")
    OR DirectoryName("Game_that_takes_up_almost_half_the_HDD")
    OR Filename("vc_redist.x64.exe")
    OR Filename("vcredist_x64.exe")
    OR Filename("vcredist_x64*.exe")
    OR Filename("*.iso")
    OR Filename("*.isz")
    OR Filename("*.mdf")
    OR Filename("*.cdi")
    OR Filename("*.pdf")
    OR Filename("*.bik")
    OR Filename("*.avi")
    OR Filename("*.wmv")
    OR Filename("*.bk2")
    OR Filename("*.mp4")
    OR Filename("*.rar")
    OR Filename("*.zip")
    OR Filename("*.7z")
    OR Filename("*.7z.*")

Run your script

With the two files that define your defragmentation logic ready, it’s time to put them to the task! Run MyDefrag and, if there’s no typo anywhere, your script should show up among the default scripts in the program’s list.

Mydefrag Your Way Run Mydefrag

Select it from the “Select a script” list. Then, as MyDefrag states, “Select 1 or more disks” from the second list you’d like to defragment based on your script’s rules. Click “Run” and give it some hours (or days, for Terabyte-large HDDs) to work its magic.

That’s it. You have defragmented and optimized your hard disk the way you want it, and it should be working better and faster now.

Odysseas Kourafalos
Odysseas Kourafalos

OK's real life started at around 10, when he got his first computer - a Commodore 128. Since then, he's been melting keycaps by typing 24/7, trying to spread The Word Of Tech to anyone interested enough to listen. Or, rather, read.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox