If you've accidentally erased an important file or folder, or if you unintentionally replaced its data with a newer version, don't fret just yet. All may not be lost. If you've been backing up your data, as you should always do, it's easy to recover an overwritten file. In fact, you can recover multiple versions of an overwritten file using Time Machine. With just a few simple clicks, your old file will be back in no time.
Open the folder where your overwritten or deleted file was located in the Finder. If it was on the Desktop, simply close all other windows.
Select "Enter Time Machine" from the Time Machine (backwards-running clock) icon in the Applications folder. Alternatively, if you have the Time Machine icon in your dock, simply select that.
Click the up arrows or a point in time on the bars at the right to "travel back in time" -- that is, to see how the folder looked in the past. Locate the file(s) or folder(s) you want to restore.
Click "Restore." If your file was deleted, it will be restored to your drive. If it was an older version, your Mac will ask you which version you want to keep -- the original (newer file), both files, or if you want to replace the original (newer file) with the older one. Make your decision and proceed.