how to detect file corruption

x_kzy_xd

Member
Jun 30, 2011
57
0
66
Sometimes, my files become corrupted without me noticing - this happens to my photos a lot. This doesn't bother me when I notice it because I have backups. It's growing to be a pain to manually go over all the photos from time to time. What can I do to automatically detect if a file has been corrupted?

So far, the only method I have found is to use MD5 checksums. But I haven't found a way to automate this.

For example, if I have a folder with 500 pictures, how I do determine if the MD5 checksums for the photos have changed since last time I checked?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,631
4,558
75
I <3 ImageMagick.
Code:
for %i in (*.jpg) do @convert %i bmp:NUL
That will attempt to convert every JPEG into a simple bitmap, then discard that bitmap. If it finds problems it should alert you. Of course if you want that in a batch file, use "%%i" instead of "%i".
 
Last edited:

Cerb

Elite Member
Aug 26, 2000
17,484
33
86
I'm lazy and put my WORM backups into archives for CRCs :), but look for "sfv" (simple file verification) software. SFV Ninja seems to be somewhat popular.

I really wish someone would make a nice GUI for PAR2 that handles subdirectories, though: two birds with one stone and all that.
 

Steltek

Diamond Member
Mar 29, 2001
3,309
1,046
136
It might not be a bad idea for you to burn a MEMTEST86+ ISO and use it to test your memory modules, one at a time, through several passes. One of the side effects of a failing memory module is often file corruption problems or file system errors.

If you haven't done it, it also might be prudent to download a diagnostic from your hard drive manufacturer's website and test your hard drive for faults as well.
 

Gooberlx2

Lifer
May 4, 2001
15,381
6
91
Could use something like fciv.

Generate checksums:
Code:
fciv.exe c:\users\x_kzy_xd\Pictures -r -type *.jpg -xml c:\users\x_kzy_xd\Documents\img_checksums.xml

Verify checksums:
Code:
fciv.exe -v -xml c:\users\x_kzy_xd\Documents\img_checksums.xml

But yeah, your images really shouldn't just corrupt for no reason all the time. I'd look into memory and/or hard disk problems, errant software, etc...
 
Last edited:

Kaido

Elite Member & Kitchen Overlord
Feb 14, 2004
50,753
6,781
136
Wow seriously? Like Steltek said, run a memtest & HDD scan ASAP. My wife has probably has 100K+ photos from her photo shoots and has never had corruption problems on either Windows or Mac.

What are you system details? OS, boot drive, etc.