Page 1 of 1

Using a batch file to verify .jpg as image files

Posted: 15 May 2009 03:45
by NTT
Hi,

Im writing a batch file that copies photo's from a memory card to our network drives.
The batch files is set to only copy .jpg's using robocopy. For maximum security we'd like to verify that each of the files is actually a genuine .jpg image file and not a renamed .exe, .zip etc.

Is there a way to accomplish this?

Thanks in advance!

Posted: 26 Aug 2009 22:38
by DccD
You may use Dump EXE file header

Code: Select all

http://www.darklich.com/download.php?oId=14


If the file is a genuine JPEG it will return nothing. If it's a PE file it will show lots of information. Unfortunately this tool does not seem to handle errorlevel but you can output the result to a text file (or any file) and check its size.
If the size equal to zero then it's not a PE file and we assume it a genuine JPEG.
If the size is greater than zero then its a PE file.

Hope it helps

Posted: 27 Aug 2009 08:33
by jaffamuffin
imagemagick using the identify command... maybe a bit ott but would do exactly as says on the tin.