ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: OntarioGuy on November 03, 2010, 10:44:48 AM

Title: Creating a list of corrupt files
Post by: OntarioGuy on November 03, 2010, 10:44:48 AM
I think this is a good tool that is totally comprehensive. I am trying to use it for a particular problem and I'm wading through the docs but I'm hoping I'd get lucky and someone would help me get there much faster.

The problem:

I had a hard drive failure and I was stupid and didn't have a good backup, I've recovered what I could and am now "picking up the pieces".

I have 1000's of jpgs and bmps scattered in many folders, I'm finding that many of them are corrupt and can't be opened.
I want to use this tool to scan through the entire drive and ideally produce a list of files which have a "file format error". It would be great of the file list included the full path.

I expect that if I was familiar with this tool, this would be possible.

Thank you for your help.
Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 03, 2010, 11:43:05 AM
I don't think the exiftool will do what you want since it is only concerned with metadata.  While it will give you lots of warnings if there are metadata problems, it won't tell you if the JPG or BMP image itself has been corrupted, and I suspect this is your main concern.

But to list all files with metadata warnings could be done like this:

exiftool -if "$warning" -r -T -filename -directory -warning DIR

(where DIR is the root image directory.  use double quotes as above if you are on Windows, or single quotes on Mac/Linux)

- Phil
Title: Re: Creating a list of corrupt files
Post by: OntarioGuy on November 03, 2010, 12:07:54 PM
Thank you so much for your help.

You're right I don't really care about the metadata but to be more specific when I run exiftool on one of these bad files it can tell that it is corrupted.

Example:

>exiftool bad.jpg
ExifTool Version Number         : 8.37
File Name                       : bad.jpg
Directory                       : .
File Size                       : 3.5 MB
File Modification Date/Time     : 2010:10:15 07:03:06-04:00
File Permissions                : rw-rw-rw-
Error                           : File format error


Even this is very useful to me and I'm trying to at least have a way of reading all files recursively, making some kind text output. At the very least I figure I can use this to open in a text editor, sort out and search through the "file format errors".

Thank you
Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 03, 2010, 12:10:53 PM
Right.  If you get an error then the file is snookered right from the beginning.

To get a list of files with errors, replace both occurrences of "warning" with "error" in my example.

- Phil
Title: Re: Creating a list of corrupt files
Post by: OntarioGuy on November 03, 2010, 12:37:55 PM
Great!

I tried it out on a little sample tree of folders that included bad files and it works!

That is very useful to me. Thank you very much.
Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 03, 2010, 12:55:46 PM
Glad I could help.

- Phil

P.S.  I'm from Ontario too (assuming you mean Ontario Canada).  Kingston to be specific.
Title: Re: Creating a list of corrupt files
Post by: evilaro on November 04, 2010, 05:29:38 AM
This is very good....

I have tried it with about 70 000 images
and has found some images that I new were no good
and also a mytest.txt that I renamed to mytest.jpg

This is a very simple and practical way to check all images we got..

Still a question..
If a image pass this test... are we sure It is OK?

Thanks

Emilio

Title: Re: Creating a list of corrupt files
Post by: evilaro on November 04, 2010, 05:55:20 AM

When I get the result of the errors, if there is a error It
gets listed... so that is fine.

But if there is no error it shows nothing..
so you get the sensations that => has it done it?

Is there a counter of the errors or similar???

Emilio
Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 04, 2010, 07:19:58 AM
QuoteIf a image pass this test... are we sure It is OK?

No.  ExifTool only issues an error if the file header is corrupted.

QuoteIs there a counter of the errors or similar???

With -if "$error", the summary at the end of the exiftool output will give this information:

"files failed condition" - the number of files without errors
"image files read" - the number of files with errors

- Phil
Title: Re: Creating a list of corrupt files
Post by: evilaro on November 04, 2010, 08:10:43 AM

Phil:

I use this...

exiftool -if "$error" -r -T -filename -directory -warning "&DIR" > errores.txt

If a error ocurs it shows
the file name and the directory
somthing like
[error.jpg          C:\IMAGES\COUNTRIES    ]

But if there is no error, the file es empty ??

So I do not see this in any case (with or without errors).

"files failed condition" - the number of files without errors
"image files read" - the number of files with errors

Emilio





Quote from: Phil Harvey on November 04, 2010, 07:19:58 AM
QuoteIf a image pass this test... are we sure It is OK?

No.  ExifTool only issues an error if the file header is corrupted.

QuoteIs there a counter of the errors or similar???

With -if "$error", the summary at the end of the exiftool output will give this information:

"files failed condition" - the number of files without errors
"image files read" - the number of files with errors

- Phil

Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 04, 2010, 09:41:48 AM
Hi Emilio,

I'm sorry, you're right.  You don't get the summary output with the -T (tabular output format) option.

Please try again without the -T.

- Phil
Title: Re: Creating a list of corrupt files
Post by: evilaro on November 07, 2010, 06:28:53 AM

Hi Phil:

Yes, now is OK....

Thanks
Emilio

PS
Regarding the summary... I wonder if it is possible to change the language.?




Quote from: Phil Harvey on November 04, 2010, 09:41:48 AM
Hi Emilio,

I'm sorry, you're right.  You don't get the summary output with the -T (tabular output format) option.

Please try again without the -T.

- Phil
Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 07, 2010, 07:20:37 AM
The -lang option currently works only for tag names and converted values.  It doesn't affect exiftool messages.

- Phil
Title: Re: Creating a list of corrupt files
Post by: evilaro on November 11, 2010, 04:43:19 AM
Phil:
The answer to a request done with the parameters comented
comes back with this.


======== E:/IM/RA001/DVD 101/MAVICAFD81/00009_Begur/MVC-006X.JPG
File Name                       : MVC-006X.JPG
Directory                       : E:/IM/RA001/DVD 101/MAVICAFD81/00009_Begur
  218 directories scanned
4684 files failed condition
    1 image files read

I feel the wording could be improved... (or it is my bad english ;)   )

Maybe

  218 directories scanned
4684 files checked for condition
    1 image files does not pass the test

Thanks

Emilio

Title: Re: Creating a list of corrupt files
Post by: Phil Harvey on November 11, 2010, 07:31:19 AM
Hi Emilio,

I think you misunderstood:

4684 files failed condition --> for these files the -if returned false and the files were not further processed

1 image files read --> this is the only file that passed

- Phil
Title: Re: Creating a list of corrupt files
Post by: evilaro on November 11, 2010, 10:24:21 AM

Hi Phil:

Yes... I misunderstood ;)

I did not realize that there was this -if  parameter.

Thanks
Emilio


Quote from: Phil Harvey on November 11, 2010, 07:31:19 AM
Hi Emilio,

I think you misunderstood:

4684 files failed condition --> for these files the -if returned false and the files were not further processed

1 image files read --> this is the only file that passed

- Phil