扫描文件夹并仅列出在该特定日期创建的.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
答案 0 :(得分:2)
您
If UCase(filesystem.GetExtensionName(objFile.name)) = "csv" then
将扩展名转换为大写,但后将其与小写“csv”进行比较。
DateAdd的第三个参数应该是日期;现在(日期)不应转换为字符串。