0
掃描文件夾並僅列出在該特定日期創建的.csv文件。如何從當前使用vbscript的文件夾獲取所有.csv文件
option explicit
dim fileSystem, folder, file, path, myDate
path = "C:\vbs"
Set fileSystem = CreateObject("Scripting.FileSystemObject")
myDate = dateadd("d", -1, FormatDateTime(Now, 2))
Set folder = fileSystem.GetFolder(path)
for each file in folder.Files
if file.DateCreated > myDate then
WScript.Echo file.Name & " created at " & file.DateCreated
If UCase(filesystem.GetExtensionName(objFile.name)) = "csv" then
Wscript.Echo objFile.Name
End If
End If
next
'DateAdd'與日期和日期字符串一起工作。然而,由於他只想要日期,所以他應該簡單地使用'DateAdd(「d」,-1,Date)'而不是將'Now'的輸出轉換爲只包含日期部分的字符串。 –