Recovering corrupted .nef files

@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.

You can use this perlscript to recover your pictures: https://owl.phy.queensu.ca/~phil/exiftool/fix_corrupted_nef.html. Use “12 bit”.

DSC_0363.NEF (21.0 MB)

8 Likes

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

1 Like

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.

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.

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

2 Likes

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!

2 Likes

@Narayan

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
Download http://owl.phy.queensu.ca/~phil/exiftool/fix_corrupted_nef_win.zip
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.

@Narayan I once experienced a corrupt SD card after camping and hiking up mountains in Italy’s Dolomites region. The SD card cost just ~35EUR, but the trip and the sweat were essentially priceless. I used http://www.cgsecurity.org/wiki/TestDisk to recover what could be recovered. Next, I used Adobe DNG Converter in batch mode to convert all the recovered files (Pentax PEF format) to DNG. I did that to filter out the hopelessly corrupt files from the usable ones. You could try that.

Never use the partition which contains the corrupted or deleted files! Don’t boot from it, don’t use it. Recover to a separate partition, preferably to separate disk if dealing with corruption (recovering to a separate partition on the same disk should be safe if dealing with deleted files, but dangerous when dealing with corrupted files/partitions/volumes/disks).

Hi everyone, sorry for the late reply, but I wanted to thank you all for your efforts! I went with Thomas Do’s suggested tool, and this worked fine for me. Thank you!

I decided to get rid of the MacBook and the sd card, to make sure this doesn’t happen anymore.

2 Likes

I have corrupted NEF files from a Nikon D7500 I am desperately trying to open. It looks like your pre-script won’t work with this model camera. Do you have anything that would work? I would be SO SO grateful. I am a total noob when it comes to this kind of data recovery. :sob:

@ClaytonJW Welcome to the forum! Have you read the whole thread? There is lots of useful info.

1. As I said above, the most important thing is to stop using the corrupted card or disk and make a bit-by-bit copy of it into an image on a separate piece of hardware. That way you would remove the chance for further corruption due to failing hardware.

2. If you don’t mind, sharing a raw file here (just drag and drop into the editor) is probably the best way to show us the sort of problem you are encountering. It is up to you of course, but it would certainly help us find a solution to your issue, which may potentially be very simple.

Adobe DNG Converter worked for me for corrupted files (accidentally deleted and then recovered from an SD card).
http://rawpedia.rawtherapee.com/How_to_convert_raw_formats_to_DNG

Hi everyone! I’m new here, and trying to recover some corrupt .NEF files. The NEF files are files that were pulled from a Seagate external drive that was accidentally wiped. I got a lot of stuff back, but have these weird .NEF files that won’t open in lightroom or preview in Finder. (I’m using Mac OS 10.14 Mojave). The files are from a D800.

I’ve already tried the remedy listed above at the website http://owl.phy.queensu.ca/~phil/exiftool/fix_corrupted_nef_win.zip. It says it completes successfully, but the copied file is just another NEF that won’t open.

I’ve also tried the Adobe DNG Converter, but out of ~900 files, only two successfully converted.

Is there any hope or another solution to hopefully get these files back? Luckily all client work was not lost, but sadly these are all personal photos from this past summer’s travels with my kiddo. We went on a couple adventures together to celebrate my being done with cancer treatments, and I would just love to still have the photos, although I’m starting to think I’ll just have to be happy with what I have. :confused: I recovered about 25% of them, but would love to get more, if at all possible. Thanks for all the above help that’s already been provided!

Hi @krista and welcome! If you still have the drive, you could try running PhotoRec, otherwise I’d be helpful to post a sample nef file.

Oh, thanks so much! I haven’t tried PhotoRec, yet. I used the Seagate Recovery software to actually recover the deleted files, and the nef file that’s attached (thanks for reminding me to attach! I meant to do that in my original reply) is an example of the files it spit out. FileNEF-0083.nef (27.4 MB)

Opens fine in nomacs 3.12 and in darktable 2.50-git1029.51b67169b
Nice capture!

Thanks for the compliment, martin.scharnke! I literally have no idea which photo that might be. :wink: I’m intrigued (and hopeful) about the fact that you can open it! I’m installing darktable now. I’ll keep you posted. Thank you all so much for your help!