将 IF 条件放入批处理文件中?
我想检查 C: 驱动器中的空间是否超过 60 GB,则应执行下一步,如果空间较小,则应显示一条消息?
为了检查磁盘空间,我可以使用“fsutil volume diskfree c:”,但我不知道如何在上述条件下使用它。
I want to check if space in C: drive is more than 60 GB then next step should be done and if space is less it should display a message?
For checking the disk space i can use "fsutil volume diskfree c:" but i dont know how to use it inside the above condition.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您可以将 1 GB 视为 109 字节,而不是 230 字节,您可以简单地
1) 通过管道传输
FSUTIL
的结果使用FIND
实用程序过滤掉不相关的行,2) 在
FOR /F
循环中使用修改后的命令行将输出存储到变量中,3) 切断最后的从变量值中提取 9 个字符,并将其余字符与所需数量进行比较。
这是我将上述步骤放在一起的尝试:
上面的脚本处理总空间。如果您想检查可用空间,请将
“# of bytes”
更改为“# of free”
。Assuming you are fine with treating 1 GB as 109 bytes, not as 230 bytes, you could simply
1) pipe the results of
FSUTIL
to theFIND
utility to filter out irrelevant rows,2) use the modified command line in a
FOR /F
loop to store the output into a variable,3) cut off the last 9 characters from the variable's value and compare the rest to the required quantity.
And here's my attempt at putting the above steps together:
The above script processes the total space. If you want to check the free space, change
"# of bytes"
to"# of free"
.基本
IF
阅读:http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true类似博客在这里发帖:
http:// fei-automation.blogspot.com/2011/02/how-to-monitor-free-space-of-group-of.html
类似的SO:CMD shell 中的可用空间
Basic
IF
reading : http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=truesimilar blog post here :
http://fei-automation.blogspot.com/2011/02/how-to-monitor-free-space-of-group-of.html
similar SO : Free space in a CMD shell