Board logo

标题: [文件操作] 谁帮下忙写1个3种情况判断的批处理啊,写一晚没搞定,郁闷。 [打印本页]

作者: smallfox5    时间: 2009-10-18 10:01     标题: 谁帮下忙写1个3种情况判断的批处理啊,写一晚没搞定,郁闷。

谁帮下忙写1个3种情况判断的批处理啊,写一晚没搞定,郁闷。
具体想实现的功能是检查C:\Program Files\Thunder Network\NetBarThunder.exe文件
1.如果大于100K以上就运行这个程序
2.如果小于100K以下就退出什么也不干
3.如果这个文件不存在就退出什么也不干
作者: Batcher    时间: 2009-10-18 10:13

如果不会使用if命令,请参考:
http://bbs.bathome.net/thread-2530-1-1.html

如果不会获取文件大小,请查看for命令的帮助:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file

作者: Seter    时间: 2009-10-18 10:37

用if exist和for in...哈哈~
作者: smallfox5    时间: 2009-10-18 10:41

if exist判断是否存在我会`已经可以``
for命令我看了一头雾水`````
搞到我晚上4点
斑竹能否帮我写1个`````
作者: canyuexiaolang    时间: 2009-10-18 11:29

呃...小狐狸??哈哈~~不是说了吗?%%~zl是那个什么扩展到文件大小
作者: smallfox5    时间: 2009-10-18 11:50

for /r "C:\Program Files\Thunder Network\" %%i in (*NetBarThunder.exe) do (
if %%~zi gtr 102400 "C:\Program Files\Thunder Network\NetBarThunder.exe"
)
搞定`发上来分享~~~谢谢村庄大牛~~




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2