I am trying to retrieve the datetaken property via diropus using vbscript.
I want to retrieve it for a specific dir, and not for a dir which is already open in diropus.
But when i try to do this using the code below, i always get the error "Invalid procedure call or argument (0x800a0005)"
option explicit
Function OnInit(initData)
initData.name = "datetaken_via_diropus"
initData.desc = ""
initData.copyright = ""
initData.version = "1.0"
initData.default_enable = false
Dim cmd
Set cmd = initData.AddCommand
cmd.name = "datetaken_via_diropus"
cmd.method = "Ondatetaken_via_diropus"
cmd.desc = ""
cmd.label = "datetaken_via_diropus"
cmd.template = ""
End Function
' Implement the datetaken_via_diropus command
Function Ondatetaken_via_diropus(scriptCmdData)
Dim objShell, objFolder, outFile, objFile, objFSOLog, strFileName
outFile="c:\temp\test.txt"
Set objFSOLog=CreateObject("Scripting.FileSystemObject")
Set objFile = objFSOLog.CreateTextFile(outFile,True)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp\temp_pic_dest\2014\09")
For Each strFileName in objFolder.Items
objFile.Write objFolder.GetDetailsOf(strFileName, 12) & ": " & objFolder.GetDetailsOf(strFileName, 0)
Next
objFile.Close
End Function
When i try to do the same thing without diropus in the vbs script below, it works perfectly:
Dim objShell, objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp\temp_pic_dest\2014\09")
For Each strFileName in objFolder.Items
Wscript.echo objFolder.GetDetailsOf(strFileName, 12) & ": " & objFolder.GetDetailsOf(strFileName, 0)
Next
folderitem.GetDetailsOf does not appear to be a useful API, since the column numbers (2nd argument) are not properly defined and change depending on which folder you are in, the operating system, and possibly other details. I suspect the API only exists because Microsoft wrapped everything in their C++ COM object model for scripts to call, without thinking about whether it made sense for them to be able to do so. With no way for a script to find out what the columns are, there is no way for the API to be useful. (I found reports that even the properly documented things like column 1 being size are not always true in all folders/situations.)
So I would not use GetDetailsOf at all, inside or outside of Opus, as it is not reliable.
Inside of Opus, you can use Metadata.image.datetaken (or image_text if you want the date in a text format). If you don't need the script code to work outside of Opus, that's the way to do it.