0

Scan folder and list only .csv files which are created on that particular day.

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
4

1 回答 1

2

您的

If UCase(filesystem.GetExtensionName(objFile.name)) = "csv" then

将扩展名转换为大写,然后将其与小写“csv”进行比较。

DateAdd的第三个参数应该是日期;现在(日期)不应转换为字符串。

于 2013-07-12T07:37:19.667 回答