?
Solved

How can I find the date property of jpg files?

Posted on 2013-01-31
3
Medium Priority
?
454 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 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