PhotoRec 

PhotoRec is an amazing little command-line (OK, text menu) utility that is able to recover photos and other file formats from memory cards (provided, of course, you took the sensible route and stopped writing to the card in any way before running it).

Notes

To recover and RAW files from some models, PhotoRec may require you to select Paranoid : Yes (Brute force enabled) from its options menu - otherwise, it will recover data without most of the information.

(with this selected you’ll get a separate file for each thumbnail - around 16K - but that’s a sensible trade-off)

As a nice bonus, PhotoRec will set the recovered files’ modification date to the original whenever possible, greatly simplifying the process of tracking down what you deleted.