Helping people with computers... one answer at a time.
Periodically defragmenting a hard drive can significantly improve its performance. I'll review how often makes sense and when you shouldn't.
How many times in a week is it good to defragment and run my anti-virus? Mostly, I run both one to two times in a week.
My most common answer is that it depends.
It depends on several things, including your machine, how you use it and how much you do. As it turns out, even the version of Windows plays a part.
I'll give you a few guidelines.
Knowing nothing else, if you run Windows XP or Windows Vista, then I recommend scheduling the defragmenter to run once a week on each drive. Schedule it to run at a time when the computer is likely to be on, of course.
How do I schedule Disk Defragmenter to run with the Windows Task Scheduler? will get you started.
You'll note that I explicitly left out Windows 7.
Windows 7 does exactly this by default.
If you open up the task scheduler in Windows 7, you'll find that there's already a weekly task to defragment the hard drives in your machine.
What if your machine isn't on when the scheduled time happens? "Run the task as soon as possible after a scheduled start is missed" is selected. And it also requires that the machine be idle for three minutes before starting so it won't necessarily interfere with your work.
For most Windows 7 owners, there's nothing more that needs to be done.
If you use your computer heavily, and I do mean heavily (creating and deleting lots of files every day, writing and erasing lots of data in various forms), then there might be a case for defragmenting more frequently.
Because defragmenting your hard drive is solely a performance tweak, this is something that you can test for yourself. A couple of days of normal usage after you defragment your hard drive, defragment it again and see if you notice a difference.
Or, just defrag nightly, as I did for years. It really doesn't harm anything.
Never, ever defragment a solid state drive (SSD) or flash drive†. There are two reasons:
It doesn't help. The performance gains achieved by defragmenting a hard drive are specifically associated with disks that use a moving magnetic head over a spinning magnetic media: in other words, a traditional hard drive. Sectors which are located completely electronically as they are with SSDs and flash drives don't slow down as files become fragmented and thus, don't speed up when you defrag.
It shortens the life of the media. Flash memory wears out the more you write to it. How quickly depends on the quality of the memory, of course, but the fact remains that the more you write to SSDs and flash memory, the sooner that it'll fail. And defragging a disk writes a lot.
There's no reason to defrag these devices and every reason not to.
Files like your paging file, hibernation file, and the system registry typically cannot be defragged by normal means because they're locked and in use by Windows itself.
First, it's OK to let that be. Windows caches so much of its file system in memory that speed impact is typically negligible.
Second, if you do feel the need to defragment these files, you needn't do it nearly as often as your regular files. Once or twice a year, maybe.
How? PageDefrag, a free tool from Microsoft. It works by scheduling the defrag operation to happen the next time that you reboot your system, before Windows is loaded.
It's probably worth doing once after you've used your system for a while or if you change the location of your paging file.
Or not at all. That's typically been my approach.
† Because SSDs are actually made from flash memory, this is technically redundant. To avoid confusion, I'm mentioning them both as many people think of them as two different things.