Android periodically rescans your internal and external SD cards so it can maintain a directory of images, mustic, videos, etc. If it gets stuck on a bad file, it can set there trying to read it forever, chewing up cpu and battery. It's definitely a bug.
So you probably have a corrupt media file, or a corrupt directory entry. Do you have a removable SD card? If so, remove it and see if that solves the problem. If so, copy off all the files, reformat the card, then add the files back. If it stays fixed, you have a corrupted directory. If the problem comes back, you've got a bad file. Delete them all, then add back just a subset. If things are OK, add another subset. Repeat until the problem recurs, then you know the problem is with that last batch of files.
If removing the SD card doesn't fix it, try copying any media (music, video, photo, etc.) files off of the internal SD card, then delete those files from the internal card. See if that solves it. If so, follow the same procedure as above to isolate the problem.