JkDefrag is a free, open source disk defragmentation program that comes in GUI, command line, and screensaver versions.
In addition to simple defragmentation, JkDefrag attempts to optimize file locations on the disk by moving those files which need faster access to the beginning of the disk, leaving little-used "space hogs" to occupy the slower portion of the disk. The program accepts a number of command line parameters to customize its behavior. Both 32-bit and 64-bit versions are available.
JkDefrag is no longer maintained. Its successor is MyDefrag, a closed-source freeware program.