'自動刪除檔案 '天數 daysAgo = 365 '路徑 dirPath = "C:\\inetpub\\logs\\LogFiles\\W3SVC6" '副檔名 extName = ".log" '---------程式開始------------ Set fs = CreateObject("Scripting.FileSystemObject") Set w = WScript.CreateObject("WScript.Shell") Set f = fs.GetFolder(dirPath) Set fc = f.Files dateBefore = Now() - daysAgo For Each ff in fc fileName = ff.Name fileDate = ff.DateLastModified If Right(fileName, Len(extName)) = extName And fileDate < dateBefore Then fs.DeleteFile(dirPath & "\\" & fileName) End If Next