Solved

How can I find the date property of jpg files?

Posted on 2013-01-31
3
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

730 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