?
Solved

How can I find the date property of jpg files?

Posted on 2013-01-31
3
Medium Priority
?
464 Views
Last Modified: 2013-01-31
Hello

I'd like to write a routine in VBA for Excel that will iterate through all the jpg files in that folder and rename them to the following format: yymmdd followed by a four digit consecutive number (0001, 0002 etc) for all photos taken on the same date.

Using the GetFile method only allows me to find the Date Created or Date Modified properties, but because the files have been copied and possibly rotated (modified) these will not always give me the date I want, which is the standard Date as viewed in Windows Explorer detailed view.

How can I find this property using VBA?

Thanks,

Chris
0
Comment
Question by:thechrisrobertstoo
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 38839325
Sample function
Function GetFileInfo(sFilePath, n)
    Dim oFolder As Object
    Dim oFolderItem As Object
    Dim sPath
    Dim sFile
    Dim lPos As Long
    
    lPos = InStrRev(sFilePath, "\")
    sPath = left(sFilePath, lPos)
    sFile = Mid(sFilePath, lPos + 1)
    Set oFolder = CreateObject("Shell.Application").Namespace(sPath)
    Set oFolderItem = oFolder.ParseName(sFile)
    If Not oFolderItem Is Nothing Then GetFileInfo = oFolder.GetDetailsOf(oFolderItem, n)
End Function

Open in new window


called for example:
Sub Testit()
    Dim n As Long
    For n = 1 To 50
        Debug.Print "n = " & n & "; " & GetFileInfo("C:\Test\backgroundDefault.jpg", n)
    Next n
End Sub

Open in new window


the date taken used to be item 25 but seems to be 12 on my Win7 system.
0
 

Author Comment

by:thechrisrobertstoo
ID: 38839372
Thanks rorya

Any idea why item 12 show the dates with question marks, eg "?01/?01/?2013 ??16:15", which the items 3 to 5 don't?

Chris
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 38839525
In all honesty, no - I'd just use Replace to get rid of them
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question