Vbscript 查找在特定日期拍摄的所有照片

Vbscript 查找在特定日期拍摄的所有照片,vbscript,photos,Vbscript,Photos,如果需要,请使用以下VBScript递归查找一组文件夹中的所有文件。我只是在网上的某个地方发现了这一点,并不能因此而获得荣誉 fileExtension = ".jpg" folderPath = "C:\Pictures" computerName = "." arrFIL = Array() If Right(folderPath,1) = "\" Then folderPath = Left(folderPath,Len(folderPath)-1) Set wmiObject = G

如果需要,请使用以下VBScript递归查找一组文件夹中的所有文件。我只是在网上的某个地方发现了这一点,并不能因此而获得荣誉

fileExtension = ".jpg"
folderPath = "C:\Pictures"
computerName = "."
arrFIL = Array()

If Right(folderPath,1) = "\" Then folderPath = Left(folderPath,Len(folderPath)-1)

Set wmiObject = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computerName & "\root\cimv2")
Set folderObject = wmiObject.Get("Win32_Directory='" & folderPath & "'")

EnumFolders folderObject, wmiObject, arrFIL
strFIL = UBound(arrFIL) + 1 & " files found with extension '" & fileExtension & "':" & vbCrLf & vbCrLf

For intFIL = 0 To UBound(arrFIL)
    Set objFile = objFSO.GetFile(arrFIL(intFIL))
    strFIL = strFIL & arrFIL(intFIL) & vbCrLf
Next
WScript.Echo strFIL

Sub EnumFolders(folderObject, wmiObject, arrFIL)
    On Error Resume Next
    Dim objSD1
    Dim objSD2
    Dim objFI1
    Dim objFI2
    Set objSD1 = wmiObject.ExecQuery("Associators of {Win32_Directory.Name='" & fold    erObject.Name & "'} Where AssocClass=Win32_SubDirectory ResultRole=PartComponent")

    For Each objSD2 in objSD1
        EnumFolders objSD2, wmiObject, arrFIL
    Next    
    On Error Goto 0

    Set objFI1 = wmiObject.ExecQuery("Associators of {Win32_Directory.Name='" & folderObject.Name & "'} Where ResultClass=CIM_DataFile")
    For Each objFI2 in objFI1
    If Right(objFI2.Name,Len(fileExtension)) = fileExtension Then
        intFIL = UBound(arrFIL) + 1
            ReDim Preserve arrFIL(intFIL)
            arrFIL(intFIL) = objFI2.Name
        End If
    Next
End Sub
我需要做的是在C:\Pictures中的一堆文件夹中运行它,并让它返回所有文件,其中照片的Date Take属性是每月23日。这可能吗?我将如何实现这一点


谢谢

我会使用
Shell.Application
对象而不是WMI:

Const Name      =  0
Const DateTaken = 12

folderPath = "C:\Pictures"

Set re = New RegExp
re.Pattern = "[^0-9:./ ]"
re.Global  = True

Traverse CreateObject("Shell.Application").Namespace(folderPath)

Sub Traverse(fldr)
  For Each obj In fldr.Items
    If obj.IsFolder Then
      Traverse obj.GetFolder
    ElseIf LCase(obj.Type) = "jpeg image" Then
      If Day(re.Replace(fldr.GetDetailsOf(obj, DateTaken), "")) = 23 Then
        WScript.Echo fldr.GetDetailsOf(obj, Name)
      End If
    End If
  Next
End Sub

谢谢你这么快就回到我身边。但是,我收到的
类型不匹配:'[string:“?23/?05/?2012?11:3”]
是一条错误消息。当我输出文件夹中所有文件的日期时,它们似乎被包装在
中,我还必须取出
ElseIf LCase(obj.Type)=“jpeg图像”,然后
用标准的
Else
替换它。我明白了。
datetake
字段似乎使用了某种编码。不过,您可以使用正则表达式简单地删除附加字符(请参见更新的答案)。对于类型,您可能需要将引用字符串(
“jpeg image”
)调整为系统上的类型名称。如果你想处理不同类型的图片,你必须扩展检查(或者如果你想处理所有文件,则完全删除检查)。非常好,非常感谢你的帮助。修改后的脚本完全符合我的需要。仅供参考,我需要将
“jpeg图像”
更改为
“jpg文件”