DEAR ALL 大大
1.需求整頓資料庫內之年代久遠無用之檔案刪除
1.1 原則如下
A. 資料夾路徑 : \\pcbfs02\C701\
B.檔案修改日期 <= 2010/01/01 前之 ALL 檔案刪除
2.請問自動化程式如何書寫 煩不吝賜教 THANKS*10000作者: jcchiang 時間: 2020-4-22 14:03
回復 1#rouber590324
試試看
引用項目 Microsoft Scripting Runtime
Sub file_Delete()
Dim myFso As Scripting.FileSystemObject
Dim myFiles As Scripting.Files
Dim myFile As Scripting.File
Set myFso = New Scripting.FileSystemObject
Path = "\\pcbfs02\C701\" '路徑請自行修正
Set myFiles = myFso.GetFolder(Path).Files
For Each myFile In myFiles
If myFile.DateLastModified < "2010/1/1" Then myFile.Delete '以檔案最後更新日判斷
Next
End Sub作者: rouber590324 時間: 2020-4-23 09:51
Dim myFiles As Object, xFile As Object
xPath = "\\pcbfs02\C701\"
Set myFiles = CreateObject("Scripting.FileSystemObject").GetFolder(xPath).Files
For Each xFile In myFiles
If xFile.DateLastModified < CDate("2010/1/1") Then xFile.Delete
Next作者: jcchiang 時間: 2020-4-23 10:37