Note: if you are pretty certain the file is still there, and the machine still boots, but Spotlight/Apple Find File/Finder navigating files in an otherwise bootable operating system in Mac OS X 10.4 or later can't find your file, go to step 6 at the bottom.
1. If the machine is under 4 years old, reset the PRAM:
Resetting the SMC or SMU can help for older models.
Note, if you are uncertain of the age, this step should not be taken, as it may make your machine even more inaccessible. If it works, your rebooting will be normal.
2. Power down your computer without shutting down through software.
3. Buy a data recovery program such as one of the below:
Prosoft Data Rescue (the only one I personally have used)
(See notes below about Alsoft Disk Warrior & Techtool Pro)
And buy an external hard drive at least the size of the original.
The data recovery program needs the ability to boot from CD that is compatible with your Mac model and age of Mac.
4 Make sure the hard drive is erased, and properly formatted for your Mac.
5. Boot off the data recovery program CD and attach the external hard drive.
Recover the data to the external hard drive.
Explanation of steps in more detail for those uncertain how to do them:
1. Step one requires no explanation.
2. Desktop computers just need the power plug pulled. Notebook computers with battery, obviously need the power pulled, and the battery removed if it is removable. Those notebooks whose battery is not removable, need the power button held a few seconds until the screen turns blank. If the sleep light is on after that, it needs the button held longer.
3. http://www.everymac.com/ will help isolate what Mac model you have. So can the link here:
Knowing its age, you can lookup the Mac operating system on http://www.wikipedia.org/ and determine what the release date of the operating system update your Mac had installed by default. That is the operating system the data recovery software needs to be able to boot from or later.
For instance, knowing that an 2013 early MacBook Pro was released February 13, 2013, the closest release date we can find is 10.8.3 on March 14, 2013.
Thus any recovery software would have to have that at minimum.
4. Properly formatting your hard drive is explained here
5. To boot from CD, the 'C' key sometimes won't work, and the option key is needed to do the startup manager (link explains what the Startup Manager
looks like on both Intel and PowerPC Macs).
If you can't get the CD to boot off your Mac, you may want to zap the PRAM if the machine is under 4 years old, or check if the PRAM battery needs replacing first if it is older.
Notes about Alsoft Disk Warrior and Techtool Pro: Unless you can get the machine to boot all the way to the desktop, to backup files, you probably shouldn't run Alsoft Disk Warrior, or Micromat Techtool Pro. You also shouldn't attempt a software installation, unless your data is backed up, as this will only decrease your chances to recover your data later. Disk Warrior can be used to repair the directory, but should only be done once you know your data is safely in two other locations. Techtool Pro has various hardware issue detection tools. Though you should also be aware how to run the hardware test that came with your Mac, both the PowerPC and Intel Mac versions.
Some Apple authorized dealers offer non-destructive data recovery services too which may have more powerful tools.
http://www.drivesavers.com/ has become an expensive, though very well recognized company for data recovery when the above tools don't work. No utility is perfect, and hence the reason you should always keep at least two backups of your data at all times. Still it is good to know in a pinch what your options may be.
And remember, backing up (tip on backing up link) your computer is not an option. It is required for the safety of your data. Backing up means having at least separate two copies off the computer of your data. They can be printed, burnt to CD, DVD, stored on an external flash drive, or an external hard drive. A simple action of deleting a file by hand can happen quite by accident, but also there is no such thing as permanent media out there. All media eventually fail. A remote backup will also ensure you won't be at as great a mercy of loss or theft. And monitor the consistency of your backup to ensure you don't have to remake it. Only you know your tolerance level for how much time you have to recreate data from scratch. Use that to determine how frequently you should backup, and just do it more frequently.
6. If a file is missing under Mac OS X 10.4 or later by file name search or navigating an otherwise bootable Finder, don't panic! Spotlight, the search engine available for file searching by content, also is tied to Apple's File menu -> Find File in the Finder, may make files missing if the index is done improperly. You can rebuild the index with Apple menu -> System Preferences -> Spotlight, adding the media to the Privacy section, and then removing it. The Spotlight menu will then reveal it is indexing. The image below shows you the Spotlight menu dropped down:
Once the menu no longer reveals the point it is indexing, then it should be ready to search the areas not put in Privacy in the preferences.
If indexing takes too long several third party file search by name options exist that do not take as long: