Re: vbscript: how to generate a FolderItem2 object from a filename ?
Newyana2 <[email protected]>
| Newsgroups | alt.comp.os.windows-xp,alt.windows7.general |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 6/22/2024 6:14 AM, R.Wieser wrote:
> Set objDlg = WScript.CreateObject("Shell.Application")
>
> '-- returns a Folder3 object
> Set oNSFolder = objDlg.NameSpace(folderName)
>
> '-- returns FolderItem2 objects
> For Each oNSFile In oNSFolder.items
>
> '-- the "Artist" property value
> sProperty = oNSFolder.GetDetailsOf(oNSFile, 16)
I'm not aware of any direct access to these compound objects.
VBS is only referencing a Folder object. In VB with early binding
it's the same. There's no sorting through versions. The following seems
to do what you want. I set it to return date rather than artist. I'm
not sure if I have a file with the artist property filled in.
Note that Namespace is available on XP, but the Self property
of a folder object is not available until IE6. That can lead to some
fairly complicated code in some cases.
Dim ObjDlg, oNSFolder, oNSFile, sProperty
Set ObjDlg = WScript.CreateObject("Shell.Application")
'-- returns a Folder3 object
Set oNSFolder = ObjDlg.NameSpace("C:\windows\desktop\fol1")
MsgBox Typename(oNSFolder)
'-- returns FolderItem2 objects.. do we care? It works.
For Each oNSFile In oNSFolder.items
If oNSFile.Name = "river.png" Then
sProperty = oNSFolder.GetDetailsOf(oNSFile, 3) 'date
MsgBox Typename(oNSFile) & vbCrLf & oNSFile.Name & vbCrLf & sProperty
End If
Next
Set oNSFolder = Nothing
Set ObjDlg = Nothing