how to detect corrupted file

Paul Norman paul at
Fri Apr 14 04:54:26 BST 2023

Hi Bob,

Yes file names passed in that way can have unknown things happening 
behind the scenes :-)

PowerShell can help here, but Dos can still do it effectively and 
quickly, as you are working in it, here are some dos shell command lines 
you could try executing.
(If you find this working, it could be converted into a batch file, once 
any other needed modifications have been worked out later. Note that %-s 
would need to be changed to %% in a .bat batch file.)

I downloaded a working copy of from exiv2 from

Looks like you got your option commands from(?):

Locally, open a dos prompt up at the top of the directory tree you want 
to explore.
If all you can see is PowerShell, then when that opens type :-

cmd <Enter>

Again, make sure you are in the top of the directory tree you want to 

The overall system PATH does not appear to need alteration, as exiv2.exe 
when called directly, appears to find all that it needs locally.
So first set your exiv2.exe file's full location, change the path to fit 
your setup, using quotes especially if you have any spaces in your .exe 
directory path. :-

set exiv2FullPath="G:\utils\exiv2-0.27.6-2019msvc64\bin\exiv2.exe"

And alter the below to your situation (change the *.exts to whatever you 
need, fewer or more, leaving a space between them):

Then execute each of these  lines one after the other :-

del results.txt & for /r  %i in (*.jpg *.jpeg *.png *.crw *.dng) do 
%exiv2FullPath% "%i"  -pp -q >> results.txt

find ": 0 x 0" results.txt > possible_corrupt.txt

notepad results.txt & notepad possible_corrupt.txt

<-- Try the above first, but if necessary, in the second command line 
above, change ": 0 x 0" to whatever is signifying your corrupt file(s) 
as shown in the file: results.txt. Copy and paste the needed text out of 
results.txt between the "quote marks" as I suspect otherwise invisible 
tabs U+0009 could be being used.

Close the notepads: for results.txt and poss_corrupt.txt - when you want 
to run the command again over the same directory tree.

At worst you can scan though the file: results.txt  manually in notepad.

Just note that the file: results.txt  will get overwritten each time you 
run the main command, so copy or rename it first if you want to keep it :-)

Hope that this will help you,

Kindest regards,

On 14/04/2023 2:16 am, plowmail2010 at wrote:
> Using Windows 7.
> I could not get wildcards to work in exiv2.
> The manual says  "$ exiv2 *.jpg Prints a summary of the Exif 
> information for all JPEG files in the directory."
> But that gives me "*.jpg: Failed to open the file".
> Also, while fiddling with this, the length of exiv2.exe went to 0.  
> Maybe the program got tired of my fiddling, or my computer is about to 
> explode.
> Bob
> On 4/13/2023 7:02 AM, frederic chaume wrote:
>> Hi All
>> I found an option using exiv2 under windows
>> >bin\exiv2.exe -pp -q P2280067_DxO-corrupted.jpg
>> Exiv2 exception in print action for file P2280067_DxO-corrupted.jpg:
>> P2280067_DxO-corrupted.jpg: The file contains data of an unknown 
>> image type
>> >bin\exiv2.exe -pp -q P2280067_DxO.jpg
>> Preview 1: image/jpeg, 317x237 pixels, 17356 bytes
>> >bin\exiv2.exe -pp -q .\P2280067.ORF
>> Preview 1: image/jpeg, 160x120 pixels, 9080 bytes
>> Preview 2: image/jpeg, 3200x2400 pixels, 1060974 bytes
>> I think that could be a good solution to find corrupted jpeg. Based 
>> on this I have some thought
>> - as exiv2 is native with Digikam, I guess such error could be 
>> visible? *Is there some "debug level" or some logs somewhere that 
>> could report such errors ?*
>> - I'm not expert on coding so don't know how to translate such 
>> command to a recursive search on a set of folders?
>> - seems to apply to raw also , but I don't have corrupted raw to 
>> perform the test
>> thanks to share your feedbacks and may be other option
>> Frederic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digikam-users mailing list