Reputation: 808
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
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
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