Using a batch file to verify .jpg as image files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 1
Joined: 15 May 2009 03:36

Using a batch file to verify .jpg as image files

#1 Post by NTT » 15 May 2009 03:45


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!

Posts: 23
Joined: 26 Aug 2009 19:34

#2 Post by DccD » 26 Aug 2009 22:38

You may use Dump EXE file header

Code: Select all

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

Posts: 40
Joined: 25 Jan 2008 14:05

#3 Post by jaffamuffin » 27 Aug 2009 08:33

imagemagick using the identify command... maybe a bit ott but would do exactly as says on the tin.

Post Reply