If you think you might need to defragment
- Try restarting first. It might help, and it’s easy to do.
- If your disks are almost full, and you often modify or create large files (such as editing video, but see the Tip below if you use iMovie and Mac OS X 10.3), there’s a chance the disks could be fragmented. In this case, you might benefit from defragmentation, which can be performed with some third-party disk utilities.
- Another option is to back up your important files, erase the hard disk, then reinstall Mac OS X and your backed up files.
Reference: About disk optimization with Mac OS X.