Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - is it possible to determine file mime type?

Reply
 
Old 06-01-2009   #1 (permalink)


Vista Home Premium 32bit
 
 

is it possible to determine file mime type?

Hallo to everybody. I'd like to know if it's possible to loop a folder searching for a specific kind of file based on its mime type and not on its extension. Thanks in advance.

My System SpecsSystem Spec
Old 06-01-2009   #2 (permalink)
Bob Landau


 
 

RE: is it possible to determine file mime type?

What are you after?

NTFS does not have file attributes that support MIME nor does the
System.IO.FileInfo which Powershell would understand.

Most crawlers map file extension to MIME which will be portable between
OS's, file systems and applications.

bob

"sardinian_guy" wrote:
Quote:

>
> Hallo to everybody. I'd like to know if it's possible to loop a folder
> searching for a specific kind of file based on its mime type and not on
> its extension. Thanks in advance.
>
>
> --
> sardinian_guy
>
My System SpecsSystem Spec
Old 06-02-2009   #3 (permalink)


Vista Home Premium 32bit
 
 

Re: is it possible to determine file mime type?

Let's suppose I have a jpg renamed with another extension, let's say txt. I'd like to know if it's possible to detect the real type of this file.
My System SpecsSystem Spec
Old 06-02-2009   #4 (permalink)
Bob Landau


 
 

Re: is it possible to determine file mime type?

I sure hope that this doesn't happen often but even if there were a MIME file
attribute how could this be guarenteed someone by accident or otherwise
couldn't change that also.

You'd need to look at the header for this particular type of file. Pretty
much all files that I know such as:

graphics
multi-media
ASCII/UNICODE
Office
EXE/OBJ/DLL/LIB

have a well known header format. Since you're making just a simple check: Is
this a mp3, wmp, ra file for instance you likely could figure this out by
reading less than 64 bytes.

Hopefully someone can chime in with a more direct solution.

bob

"sardinian_guy" wrote:
Quote:

>
> Let's suppose I have a jpg renamed with another extension, let's say
> txt. I'd like to know if it's possible to detect the real type of this
> file.
>
>
> --
> sardinian_guy
>
My System SpecsSystem Spec
Old 06-02-2009   #5 (permalink)


Vista Home Premium 32bit
 
 

Re: is it possible to determine file mime type?

Thank you very much Bob. I don't have any real problem to face.
It's just a curiosity that I have.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Determine OS version and bit type from the registry Vista General
What is the MIME type of Windows Powershell script files (.ps1 fil PowerShell
Windows does not recognize this MIME type. Vista General
Setting up the Coldfusion document type in MIME mapping on IIS 7.0 Beta Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46