Hi guys,

I am downloading a lot of jpg files from the web for a project the only
problem is sometimes they are bitmap files with the wrong file
extension. Windows appears to be cool with this however the script
loads them into photoshop which just makes the whole thing fall over.

Is there a way using windows scripting to check that a jpg is actually
that and if not to spit the file out and not process it.

Many thanks in advance.

Re: VB to read a file to work out what it really is by hempguy

hempguy
Thu Oct 12 07:45:52 CDT 2006

If LCase(Right([filename], 3)) <> "jpg" Then
its not a jpg
End If




<botters@gmail.com> wrote in message
news:1160653378.187303.150660@h48g2000cwc.googlegroups.com...
> Hi guys,
>
> I am downloading a lot of jpg files from the web for a project the only
> problem is sometimes they are bitmap files with the wrong file
> extension. Windows appears to be cool with this however the script
> loads them into photoshop which just makes the whole thing fall over.
>
> Is there a way using windows scripting to check that a jpg is actually
> that and if not to spit the file out and not process it.
>
> Many thanks in advance.
>



Re: VB to read a file to work out what it really is by mayayana

mayayana
Thu Oct 12 08:07:14 CDT 2006

JPGs are less regular than BMPs. If BMP
is the only problem type it's easier to
check for that: The first 2 bytes are "BM"
or 66-77.

JPG files typically have 4 bytes that spell
"JFIF", starting at the 7th byte, but I'm not
certain that's required for the format. A lot
of companies make up their own JPG
rules and much of it seems to be defaults
rather than standards.

Unfortunately, there's been a persistent
myth that renaming a BMP to JPG makes
it so. That might be the problem you're running
into.

>
> I am downloading a lot of jpg files from the web for a project the only
> problem is sometimes they are bitmap files with the wrong file
> extension. Windows appears to be cool with this however the script
> loads them into photoshop which just makes the whole thing fall over.
>
> Is there a way using windows scripting to check that a jpg is actually
> that and if not to spit the file out and not process it.
>
> Many thanks in advance.
>



Re: VB to read a file to work out what it really is by botters

botters
Thu Oct 12 08:07:40 CDT 2006

Ah sorry may not have explained well enough.

The Bitmap filename is image.jpg. if I change it to image.bmp then it
will work fine in photoshop but I need the Script to read the File and
work out that even though it ends with a jpg extension it is in fact
not one.

Any ideas?

Thanks

On Oct 12, 1:45 pm, "hempguy" <h...@guy.com> wrote:
> If LCase(Right([filename], 3)) <> "jpg" Then
> its not a jpg
> End If
>
> <bott...@gmail.com> wrote in messagenews:1160653378.187303.150660@h48g2000cwc.googlegroups.com...
>
>
>
> > Hi guys,
>
> > I am downloading a lot of jpg files from the web for a project the only
> > problem is sometimes they are bitmap files with the wrong file
> > extension. Windows appears to be cool with this however the script
> > loads them into photoshop which just makes the whole thing fall over.
>
> > Is there a way using windows scripting to check that a jpg is actually
> > that and if not to spit the file out and not process it.
>
> > Many thanks in advance.- Hide quoted text -- Show quoted text -


Re: VB to read a file to work out what it really is by Walter

Walter
Thu Oct 12 08:07:33 CDT 2006

<botters@gmail.com> wrote in message
news:1160653378.187303.150660@h48g2000cwc.googlegroups.com...
> Hi guys,
>
> I am downloading a lot of jpg files from the web for a project the only
> problem is sometimes they are bitmap files with the wrong file
> extension. Windows appears to be cool with this however the script
> loads them into photoshop which just makes the whole thing fall over.
>
> Is there a way using windows scripting to check that a jpg is actually
> that and if not to spit the file out and not process it.
>
> Many thanks in advance.
>

When opened in a text editor, AFAIK the first two characters of a true BMP
file are always BM.