Created
October 5, 2011 03:20
-
-
Save lyhcode/1263540 to your computer and use it in GitHub Desktop.
刪除過期的檔案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'*********************** | |
'刪除過期的檔案(VBScript) | |
'*********************** | |
'天數 | |
daysAgo = 3 | |
'路徑 | |
dirPath = "C:\\test" | |
'副檔名 | |
extName = ".bak" | |
';;;;;程式開始;;;;; | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment