【发布时间】:2015-12-04 06:41:51
【问题描述】:
有没有办法在 windows batch/PowerShell 中找出文件的 MIME-TYPE(或者称为“Content-Type”...)?
【问题讨论】:
标签: windows batch-file content-type
有没有办法在 windows batch/PowerShell 中找出文件的 MIME-TYPE(或者称为“Content-Type”...)?
【问题讨论】:
标签: windows batch-file content-type
虽然不是直接在 Windows 命令提示符中,但更现代的方法是使用 Git for Windows。安装后,运行git-bash 和命令file path\to\file。一个示例输出可能是:
TestFile.ico: MS Windows icon resource - 1 icon, 128x128, 32 bits/pixel
或者,使用命令file -i path\to\file 可能会给出:
TestFile.ico: image/vnd.microsoft.icon; charset=binary
【讨论】:
mv 批处理来修复文件扩展名。也许有更多时间的人可以自动化这个过程:)
使用File from source 或者您可以使用get win32 binaries from here
空文件示例:
COPY NUL >test.ext && "C:\Program Files (x86)\GnuWin32\bin\file" −-mime-type test.ext
这将返回:
test.ext; text/plain
更新:
另外,-b 或 --brief 不要在输出行前添加文件名
file -b −-mime-type test.ext 仅返回 mime 类型:text/plain
输入 file --help 了解更多选项
注意:源比 GnuWin32 提供给我们的可执行文件更新得多。
【讨论】: