eld*_*blz 6 windows content-type batch-file
有没有办法在 Windows 批处理/PowerShell 中找出文件的 MIME-TYPE(或者它被称为“Content-Type”...)?
Ala*_*inD 10
虽然不是直接在 Windows 命令提示符下,但更现代的方法是使用Git for Windows。安装后,运行git-bash
命令file path\to\file
. 示例输出可能是:
TestFile.ico: MS Windows icon resource - 1 icon, 128x128, 32 bits/pixel
Run Code Online (Sandbox Code Playgroud)
或者,使用file -i path\to\file
可能给出的命令:
TestFile.ico: image/vnd.microsoft.icon; charset=binary
Run Code Online (Sandbox Code Playgroud)
使用源文件,或者您可以从这里获取 win32 二进制文件
来自空文件的示例:
COPY NUL >test.ext && "C:\Program Files (x86)\GnuWin32\bin\file" ?-mime-type test.ext
Run Code Online (Sandbox Code Playgroud)
这将返回:
test.ext; text/plain
Run Code Online (Sandbox Code Playgroud)
更新:
也-b
或--brief
不要在输出行前添加文件名
file -b ?-mime-type test.ext
仅返回 MIME 类型: text/plain
键入file --help
更多的选择
注意:这些源代码比 GnuWin32 好心提供给我们的可执行文件更新得多。