Recovering corrupted .nef files


Hello everyone, we recently made a small trip and took our pictures in .nef format. When the storage on our sd card was full we put everything on an old macbook that we take along on our trips.

We had to move the folder around on the mac because of some freezing problems.

When I copied everything from our macbook to our workstation I noticed that the .nef files couldn’t be opened anymore (the newer pics we took and which were moved directly from the sd to our workstation open fine). The only software that seems to do something is Gimp, which displays some kind of thumbnail of the image (photoshop fails completely!). Anyone who would’ve encountered a similar issue or would have some tricks to retrieve the images?

I’m quite a noob with this so I’m a bit lost, I hope our pictures are not totally destroyed.

One difference wit the “corrupt” files I found out is that all information on camera model seems to be erased if I check the image characteristics on Windows.

(Mica) #2

You can try PhotoRec on both the SD Card and hard disk of the Mac:


DSC_0363.NEF (21.0 MB)

I attached one of the files to illustrate the problem.


@PaperDigits, I’ll try this out tomorrow (have to get some sleep now). Is this designed to find lost pictures or to repair damaged/corrupted files?

(Mica) #5

Find files on corrupted disks.

(Glenn Butcher) #6

I couldn’t open it with any of the raw converters I have. I ran exiftool on it to look at the metadata, which appears to be intact, as well as the JpgFromRaw and PreviewImage jpegs that NEFs normally contain. I did find another image, called “OtherImage”, it extracted to another jpeg.

What are you camera model and raw converter name/version?

If this NEF is consistent with the others, you should at least be able to salvage the embedded jpeg.


Hi Glenn, thanks for the effort!
The camera is a Nikon D5300.

My wife uses Photoshop (my efforts to convert remain fruitless… ) and I am more a Gimp/G’mic hobbyist, but I normally don’t use raw myself.

What would the best way be to try to salvage the embedded JPEG?

Edit: spelling


@Narayan As a fellow hobbyist, I hope I can help. See below.


A day ago I wrote a post on exiftool that you might find useful: [Solved] Fast raw to jpg?. The largest embedded image is probably PreviewImage but follow the instructions to find out.


PhotoRec and TestDisk are a powerful set of tools. They are not the easiest to use but I have recovered seemingly unrecoverable files and filesystems with them. When you first use PhotoRec, the results may be disappointing. Just tweak the settings and try again until you get a desired outcome.

Advice based on my personal experience:

  1. File loss and / or corruption: along the way, something went wrong. Maybe it had to do with the copying over, or maybe it had to do with the integrity of SD card or hard drive or their controllers… Looks like there were multiple points where something could have gone wrong.

  2. Start as close to where the files were generated as possible. That would be the SD card. Since it is relatively inexpensive to replace, don’t take another chance with it in the future. It might fail on you again.

  3. Make a disk image of the card in case it is faulty (or file / folder image if you are dealing with individual folders / files). That way you can use an app like PhotoRec, which can wear the card even more, without worrying about it dying completely.

    Edit: please note that this image must be written to a separate hardware storage device, otherwise this precaution won’t work. Also, consider generating an image that is a bit-by-bit copy. It is a much slower and resource heavy process but it is worth it for apps that can take advantage of that.

  4. Do multiple searches with the same and different settings.

  5. Depending on your settings, the file type you are looking for, and how corrupt or old (overwritten) the files are; you might get files that are unnamed or have a funny name. Files can also have missing metadata, as you described above, or they may be missing information (partial images). You may find traces of very old files if they weren’t overwritten enough to disappear completely.

(Shreedhar Inamdar) #9

Hello @Narayan I just changed the name of the topic from a general problem to the specific one. It will be easier for future reference. I hope you do not mind.


Hi Afre, thanks a lot for your detailed explanation.

I think the problem originates from the macbook, where we had to move the folder with the images from the desktop because it was slowing down/freezig the system.

The sd card has been used since, also during our journey, but I’ll give it a try anyway.

Ps: I don’t mind the title change at all.


@Narayan Which MacBook model and OS version were you using?

As mentioned, there might be one or a number of points of failure, so I would start with the SD card and then move along the file transfer timeline.

Because you used the SD card after encountering the problem, chances are that some or all of the files that you would like to recover have been partially or fully overwritten to the point where recovery isn’t easy. So, you would still benefit from checking the files on the MacBook and then on the workstation.

Again, it would be wise to create an image of those files or folders on a separate disk, so that when you examine them you wouldn’t risk further hardware, software or firmware failure.

(Thomas) #12

You can use this perlscript to recover your pictures: Use “12 bit”.

DSC_0363.NEF (21.0 MB)

(Pat David) #13

Someone buy this guy a beer. Nice find on a solution, @Thomas_Do!


Just know what this utility is and isn’t for (as detailed on the page). It will definitely modify your files; backup before using it.

(Thomas) #15

As far as I can see it just produces a new output file. But I did not check the code. So, better safe than sorry :-).


Here is an anecdote that illustrates the importance of backing up:

A few years ago, when I was recovering a friend’s lost data, Windows kindly offered to fix a corrupted SD (or group of files – don’t remember which). I was sleepy and did not realize that I had clicked yes. The fix turned out to be something undesirable but there was no going back. It made the recovery much harder, and impossible for certain images.

(Glenn Butcher) #17

As others have pointed out exiftool can do this.

I ran the following on your sample NEF:

$ exiftool -s DSC_0363.NEF |grep Binary
JpgFromRaw                      : (Binary data 2520615 bytes, use -b option to extract)
OtherImage                      : (Binary data 813454 bytes, use -b option to extract)
PreviewImage                    : (Binary data 132826 bytes, use -b option to extract)
ThumbnailTIFF                   : (Binary data 57816 bytes, use -b option to extract)

The biggest image is the JpgFromRaw, so that’s what you should probably salvage. Here’s the command that would do that:

$ exiftool -b -JpgFromRaw DSC_0363.NEF > DSC_0363.jpg


Hi everyone, what an awesome community! Thanks a lot for all your valuable advice and hard work! I’ll try out the suggested methods, but family life and work are preventing me from getting a lot of computer time. As soon as I try this out I’ll give you feedback!

(Thomas) #19


I first tested the procedure on linux (my favorite OS :slight_smile: ) but it also works fine on windows.

Choose a disk with a lot of space
Unpack the zip archive into an empty folder
Copy all files you want to repair into this folder with the fix_corrupted_nef.exe application in it
Select all .NEF files and drag & drop the files with the mouse onto the application icon
Choose 12 bit
You will get a new folder named »fixed« containing the repaired files

For me, the repaired files look like normal RAWs. I do not know how many files you can transform at once but three worked fine :wink: .


Although this is not what this Phil Harvey’s excellent tool was designed to do, it is always worth trying with broken NEF files. It often creates nice surprises.