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

前端 未结 2 1543
执笔经年
执笔经年 2020-12-21 02:38

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

相关标签:
2条回答
  • 2020-12-21 03:01

    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
    
    0 讨论(0)
  • 2020-12-21 03:12

    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.

    0 讨论(0)
提交回复
热议问题