首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检查日期和扩展名的Vbs脚本

检查日期和扩展名的Vbs脚本
EN

Stack Overflow用户
提问于 2012-07-04 19:11:00
回答 1查看 346关注 0票数 0

嗨,我不能得到下面的脚本,我工作的文件的扩展名,任何人可以帮助我指出我哪里错了?

代码语言:javascript
复制
dim fileSystem, folder, file 
dim path
dim count : count = 0
path = "C:\temp" 

Set fileSystem = CreateObject("Scripting.FileSystemObject") 
Set folder = fileSystem.GetFolder(path)

for each file in folder.Files     
    if file.DateLastModified > dateadd("h", -24, Now) & File.name = "txt" then 

count = count + 1

end if
Next

if count < 4 then

Set WshShell = WScript.CreateObject("WScript.Shell")
strcommand = "eventcreate /T ERROR /ID 666 /L Application /SO BESROffsite /D " & _  
Chr(34) & count & " Files found please check offsite copy " & Chr(34)  
WshShell.Run strcommand
wScript.Quit ( 1001 )

Else

Set WshShell = WScript.CreateObject("WScript.Shell")
strcommand = "eventcreate /T Information /ID 666 /L Application /SO BESROffsite /D " & _  
Chr(34) & count & " Files found offsite is working fine " & Chr(34)  
WshShell.Run strcommand
wScript.Quit ( 0 )
End if
EN

回答 1

Stack Overflow用户

发布于 2012-07-04 23:27:26

Alex的答案是你想要的,但仅供参考,如果你只使用vbs和字符串文件名,没有filesystemobject集合,你可以通过:

代码语言:javascript
复制
Right(strFilename, Len(strFilename) - Instrrev(strFilename, "."))

这本质上是找到了最终的位置“。在filename中,从你的文件名的长度中去掉它,然后从右边给出多少个相等的字符。这可以稍微修改一下,使用"Mid“命令而不是"Right”命令,但我认为在这种情况下这并不重要。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11327918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档