Getting DatePictureTaken property 
Author Message
 Getting DatePictureTaken property

I am trying to get the property DatePictureTaken on a File object.  I am
using the FileSystemObject and the create date and last modified date on a
bunch of my picture files are wrong.  I noticed that on most of my files
there is a property in explorer called DatePictureTaken.  I assume this is
new with Windows XP and I am trying to figure out how to query it within
VBScript WSH.  I have all the other fields taken care of.


Wed, 15 Dec 2004 20:26:05 GMT  
 Getting DatePictureTaken property
:: I am trying to get the property DatePictureTaken on a File object.
:: I am using the FileSystemObject and the create date and last
:: modified date on a bunch of my picture files are wrong.  I noticed
:: that on most of my files there is a property in explorer called
:: DatePictureTaken.  I assume this is new with Windows XP and I am
:: trying to figure out how to query it within VBScript WSH.  I have
:: all the other fields taken care of.

Here's an example of listing all of the extended properties of a file.  The example uses the running script as the file whose extended proiperties are listed.  

On my Win2K Pro sp2 box, there seems to be a maximum of 38 extended properties (indexed 0 thru 37), DatePictureTaken *not* being one of them so that must be an XP thing.  

On WinXP, I suggest you experiment with something larger 37 as the upper bound of arrHeaders in order to find out what index value corresponds to DatePictureTaken.

Set objShell = CreateObject ("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
thisScript = WScript.ScriptFullName
strParentFolder = objFSO.GetParentFolderName(thisScript)
strFileName = objFSO.GetFileName(thisScript)
Set objFolder = objShell.Namespace (strParentFolder)
Dim arrHeaders(37)
For i = 0 to UBound(arrHeaders)
  arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
set objFolderItem = objFolder.ParseName(strFileName)
For i = 0 to UBound(arrHeaders)
  If i <> 9 then
    Wscript.echo i, arrHeaders(i) _
        & ": " & objFolder.GetDetailsOf (objFolderItem, i)
  End If
Next

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Thu, 16 Dec 2004 02:36:03 GMT  
 Getting DatePictureTaken property


:: I am trying to get the property DatePictureTaken on a File object.
:: I am using the FileSystemObject and the create date and last
:: modified date on a bunch of my picture files are wrong.  I noticed
:: that on most of my files there is a property in explorer called
:: DatePictureTaken.  I assume this is new with Windows XP and I am
:: trying to figure out how to query it within VBScript WSH.  I have
:: all the other fields taken care of.

Here's an example of listing all of the extended properties of a file.  The
example uses the running script as the file whose extended proiperties are
listed.

On my Win2K Pro sp2 box, there seems to be a maximum of 38 extended
properties (indexed 0 thru 37), DatePictureTaken *not* being one of them so
that must be an XP thing.

On WinXP, I suggest you experiment with something larger 37 as the upper
bound of arrHeaders in order to find out what index value corresponds to
DatePictureTaken.

Set objShell = CreateObject ("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
thisScript = WScript.ScriptFullName
strParentFolder = objFSO.GetParentFolderName(thisScript)
strFileName = objFSO.GetFileName(thisScript)
Set objFolder = objShell.Namespace (strParentFolder)
Dim arrHeaders(37)
For i = 0 to UBound(arrHeaders)
  arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
set objFolderItem = objFolder.ParseName(strFileName)
For i = 0 to UBound(arrHeaders)
  If i <> 9 then
    Wscript.echo i, arrHeaders(i) _
        & ": " & objFolder.GetDetailsOf (objFolderItem, i)
  End If
Next

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--
-----------------------------------------------------
Turns out that it is item#25 in Windows XP.  Thanks a bunch for the help - I
know I would never have found this on my own, I certainly looked all over.
I think I have taken the *long* way to get this information for all my
files, since I just copied your code and used the code I had to iterate
through the files.  Here is the code I used - I know it is not very
efficient, but it seems like the file object does not have the methods I
need:

' myFolderPath  is the path where the pictures are located
' strValid is a constant equal to the file types I care about -
'.gif.jpg.png'
 Dim arrHeaders(37)

 Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
 Set objShell = CreateObject ("Shell.Application")

 If objFSO.FolderExists(myFolderPath) Then
    Set objPicturesFolder = objFSO.GetFolder(myFolderPath)
  For Each objFile in objPicturesFolder.Files
         strFile = LCase(objFile.name)
         If Instr(strValid,Right(strFile,4)) Then
    count = count + 1
    strParentFolder = objFSO.GetParentFolderName(objFile.Path)
    strFileName = objFSO.GetFileName(objFile.Path)
    Set objFolder = objShell.Namespace (strParentFolder)
    For i = 0 to UBound(arrHeaders)
       arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
    Next
    set objFolderItem = objFolder.ParseName(strFileName)
    For i = 0 to UBound(arrHeaders)
       If i = 25 then
          Wscript.echo i, arrHeaders(i) & ": " & objFolder.GetDetailsOf

(objFolderItem, i)
       End If
    Next
   End If
  Next
 Else
  MsgBox "Folder: " & myFolderPath & " not found"
 End If



Thu, 16 Dec 2004 03:51:22 GMT  
 Getting DatePictureTaken property
::     For i = 0 to UBound(arrHeaders)
::        arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
::     Next
::     set objFolderItem = objFolder.ParseName(strFileName)
::     For i = 0 to UBound(arrHeaders)
::        If i = 25 then
::           Wscript.echo i, arrHeaders(i) & ": " & objFolder.GetDetailsOf(objFolderItem, i)
::        End If
::     Next
::    End If

If the DatePictureTake property has in index of 25 on XP then all of the code above can be reduced to:

Wscript.echo "DatePictureTaken: " _
    & objFolder.GetDetailsOf(objFolderItem, 25)

I actually baseded the example I posted on examples in the 'System Administration Scripting Guide Script Repository' which can be downloaded from:

System Administration Scripting Guide
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

They are also available online at:

Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

All of the samples in the 'System Administration Scripting Guide Script Repository' that illustrate the use of the GetDetailsOf method are misleading in the use of the variable name strFileName.

Using the 'Retrieve Detailed Summary Information for a File' sample as a case in point:

For Each strFileName in objFolder.Items
    For i = 0 to 13
        If i <> 9 then
            Wscript.echo arrHeaders(i) _
                & ": " & objFolder.GetDetailsOf (strFileName, i)
        End If
    Next
    Wscript.Echo
Next

Enumerating objFolder.Items with For Each does not return a string, it returns a FolderItem object.  Nor does the GetDetailsOf method take a string as its first argument, it takes a FolderItem object.

This and the other samples would have been better written as:

For Each objFolderItem in objFolder.Items
    For i = 0 to 13
        If i <> 9 then
            Wscript.echo arrHeaders(i) _
                & ": " & objFolder.GetDetailsOf (objFolderItem, i)
        End If
    Next
    Wscript.Echo
Next

Since I don't have a copy of the 'System Administration Scripting' Guide book, I don't know if the chapter text that references these samples makes that clear.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Thu, 16 Dec 2004 04:27:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Getting properties from a linked document (How)?

2. File access - Getting last updated property of a file

3. Trouble getting the default property to work in ASP

4. Problem with getting properties of the window object

5. Help getting users by Exchange property

6. getting file properties

7. Getting standard document properties

8. Getting shortcut properties

9. Getting WinNT 4 User's domain properties

10. getting query string from frame in jscript and getting frame name from another frame

11. Property Let, Property Get

12. node.text = val: true gets "-1", false gets "0" at setting node text

 

 
Powered by phpBB® Forum Software