嗨,我不能得到下面的脚本,我工作的文件的扩展名,任何人可以帮助我指出我哪里错了?
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发布于 2012-07-04 23:27:26
Alex的答案是你想要的,但仅供参考,如果你只使用vbs和字符串文件名,没有filesystemobject集合,你可以通过:
Right(strFilename, Len(strFilename) - Instrrev(strFilename, "."))这本质上是找到了最终的位置“。在filename中,从你的文件名的长度中去掉它,然后从右边给出多少个相等的字符。这可以稍微修改一下,使用"Mid“命令而不是"Right”命令,但我认为在这种情况下这并不重要。
https://stackoverflow.com/questions/11327918
复制相似问题