While using OS X, you may discover a folder at the root of the hard drive, called Damaged Files. You may wonder why it's there and what's in it.
This folder, which less commonly is found at the root of secondary storage volumes you have mounted, results from the system's automatic file system checking routines (fsck). These routines may run after a power failure, a, or if you boot to Safe Mode by holding the Shift key at startup. In this routine, the system will check the inodes in the file system structure (folders and documents are types of inodes), and if there is a problem with the file where the inode needs to be freed, instead of deleting the file contents referenced at that inode, the system will salvage it in a new file and save it in the Damaged Files folder.
For the most part, the contents of these files will be garbled inode structure information that is useless, but every now and then it may contain information from files you may have been working on immediately before a fault such as a system crash or power failure occurred.
If you find this Damaged Files folder on your hard drives right after a crash, you can try opening some of the files (especially the larger ones) to see if you can read any contents, but otherwise for the most part you should be able to remove the files without losing any data. The default file system format that Apple uses is a journaled one, meaning that anything written to disk will first be saved to a small cache to ensure that it is properly written. This routine should ensure that file system writes are complete or not performed at all; if a write routine is interrupted, the system should delete it and try again instead of leaving a partially written file on the drive.
Overall, the presence of a Damaged Files folder should not be cause for alarm; you can likely remove it without fear of losing data. But you should keep an eye on it to ensure that it's not an indication of a greater problem. If the hard drive's file system formatting is corrupted, or if it's otherwise malfunctioning, it may regularly create these files during disk checks and you might see them accumulate.
In these cases, you can check the hard drive further by booting to the OS X Recovery HD partition (or to an OS X installation disc) and using Disk Utility to run a complete verification and repair of the hard drive's volumes and partition tables. Another approach is to simply back up your data fully using Time Machine, and then fully partition and format the drive using Disk Utility (again done from the OS X Installer or Recovery HD partitions) before restoring your data back to it.
If the problem continues to occur, especially if it's coupled with the presence of regular errors showing up when you check with Disk Utility, consider replacing the drive, as it is likely failing.