仅用于文件大小的 Windows 命令 [英] Windows command for file size only
问题描述
是否有 Windows 命令可以像这样输出指定文件的大小(以字节为单位)?
Is there a Windows command that will output the size in bytes of a specified file like this?
> filesize test.jpg
65212
我知道 dir
命令会输出此信息,但是它还输出其他信息.
I know that the dir
command outputs this information, but it outputs other information also.
我可以轻松编写这样的程序,但如果可能,我更愿意使用本机 Windows 命令,或者仅使用全新安装的 Windows XP 中可用的命令.
I could easily write such a program, but I would prefer to use a native Windows command if possible, or only what is available in a fresh install of Windows XP.
推荐答案
如果您在批处理脚本中,您可以使用参数变量技巧来获取文件大小:
If you are inside a batch script, you can use argument variable tricks to get the filesize:
文件大小.bat:
@echo off
echo %~z1
这会产生与您在问题中建议的结果类似的结果.
This gives results like the ones you suggest in your question.
类型
help call
在命令提示符处查看所有疯狂的变量操作选项.另见 这篇文章了解更多信息.
at the command prompt for all of the crazy variable manipulation options. Also see this article for more information.
这仅适用于 Windows 2000 及更高版本
This only works in Windows 2000 and later
这篇关于仅用于文件大小的 Windows 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!