eldblz
eldblz

Reputation: 808

How can I find out a files “mime-type(Content-Type?)”? on Windows

Is there a way to find out the MIME-TYPE (or is it called "Content-Type"...) of a file in windows batch/PowerShell?

Upvotes: 12

Views: 30913

Answers (2)

AlainD
AlainD

Reputation: 6587

While not directly in the Windows command prompt, a more modern approach is to use Git for Windows. Once installed, run git-bash and the command file path\to\file. An example output might be:

TestFile.ico: MS Windows icon resource - 1 icon, 128x128, 32 bits/pixel

Alternatively, use the command file -i path\to\file which might give:

TestFile.ico: image/vnd.microsoft.icon; charset=binary

Upvotes: 18

Paul
Paul

Reputation: 2710

Use File from source or you can get win32 binaries from here

Example from empty file:

COPY NUL >test.ext && "C:\Program Files (x86)\GnuWin32\bin\file" −-mime-type test.ext

Which will return this:

test.ext; text/plain

Update:

Also -b or --brief do not prepend filenames to output lines

file -b −-mime-type test.ext return only the mime-type: text/plain

Type file --help for more options

Note: The sources are much more recent than the executable file kindly made available to us by GnuWin32.

Upvotes: 8

Related Questions