To check hundreds of JPEGs for corruption at once, use a batch scanning tool that tests every file's structure and data stream. A single command can scan an entire folder, faster than opening each image by hand. Batch checking with free command line tools finds corrupt images in a folder and verifies photo backup integrity before it is too late. Only the files flagged as damaged need to be repaired.
Why Thumbnails Are Not Enough
A common mistake is assuming a photo is intact because a thumbnail appears in your file browser. Many thumbnails come from the small embedded Exif preview, not the full image. A corrupted main data stream can still leave that preview readable. To truly check for corruption, decode the entire JPEG file and verify its structure. A file that decodes without warnings has a complete, readable data stream.
Using Jpeginfo to Batch Check JPEG Files
jpeginfo is a free command line tool that checks JPEG files and marks each one as [OK], [WARNING] or [ERROR]. To scan all JPEGs in the current folder, open a terminal, navigate to the folder, and run:
jpeginfo -c *.jpg
This command processes every .jpg file and prints a line for each with its status. Files marked [WARNING] or [ERROR] are damaged or suspect. Redirect the output to a text file for review:
jpeginfo -c *.jpg > scan_results.txt
For folders with subfolders, use a recursive approach. On Linux or macOS, run:
find . -name "*.jpg" -exec jpeginfo -c {} \;
What the Statuses Mean
- [OK] The file is intact and decodes correctly.
- [WARNING] Minor issues found; the file may still open but could have hidden problems.
- [ERROR] The file is corrupt and will not decode normally. These are the files you need to repair.
Using ImageMagick to Identify Corrupt JPEGs
ImageMagick decodes every file and reports problems. To check a single file, run:
magick identify -regard-warnings photo.jpg
Older versions of ImageMagick use identify without the magick prefix. To batch check all JPEGs in a folder, use a loop. On Windows (PowerShell):
for %f in (*.jpg) do magick identify -regard-warnings "%f"
On Linux or macOS:
for f in *.jpg; do magick identify -regard-warnings "$f"; done
Any file that produces a warning or error message is suspect. A clean file outputs its geometry and color space without complaint.
Checking for Truncated Files
A JPEG should end with the End Of Image marker FF D9. A missing marker is a strong sign of truncation. Search for this marker across many files using a hex dump tool or a simple script. On Linux, xxd and grep can find files that lack the ending marker. The jpeginfo and ImageMagick methods already detect truncation as part of their checks.
How to Scan a Photo Backup Folder
To verify photo backup integrity, check every JPEG in the backup location. The process is the same as scanning any folder, but with a larger scope. Run your chosen tool on the top level of the backup folder. For a deep directory tree, use the recursive options described above. Collect the list of damaged files and compare it against the original source. If the backup contains corrupt files that the original does not, restore fresh copies. If both are corrupt, repair the damaged files.
Checking after every card import catches damage while the card still holds the originals. This habit prevents you from discovering problems only after you have erased the memory card.
Automating the Scan with a Simple Script
For regular checks, create a script that runs your chosen tool and saves a report. Here is a basic example for Linux or macOS using jpeginfo:
- Open a text editor and create a file named scan_jpegs.sh.
- Add these lines:#!/bin/bashfind "$1" -name "*.jpg" -exec jpeginfo -c {} \; > scan_report.txtecho "Scan complete. Results in scan_report.txt"
- Save the file and make it executable: chmod +x scan_jpegs.sh
- Run it with the folder path as an argument: ./scan_jpegs.sh /path/to/photos
Adapt this to use ImageMagick instead. Replace the jpeginfo -c part with magick identify -regard-warnings.
What to Do with the Damaged Files
Only files flagged as damaged need to be repaired. Do not waste time re-encoding healthy photos. Once you have a list of broken files, attempt repair. Use a dedicated repair tool like the one at jpeg.repair. That site recovers corrupted JPEG files online for free with no watermark. Upload only the damaged files and download the repaired versions. For severe corruption, recovery may not be possible, but many truncation and checksum issues are fixable.
Preventive Scanning Habits
Incorporate batch checking into your regular workflow. After every photo session, run a scan on the import folder before deleting the memory card. Periodically scan your main photo library and any backup drives. This routine finds corrupt images in a folder early, when you still have the best chance of recovery. A file that decodes without warnings today may still fail in the future due to bit rot, so recheck backups every few months.