Okay! After a long weekend, I think I got it to work exactly as needed (without the renaming part for now).
It was annoying that I could not use the standard function "Format("D#yyyyMMdd_T#HHmmss")" on the meta data (still don't understand why it works on modified date but not on Date Taken), so I tried replacing the dates via regex but it was not possible to do with converting am to 24 hour time. So I found out that you can pull the different date parts from the using something else. So I took apart the date taken date into 6 parts and put it back together. It looks long and clumsy now but it works fine.
Thanks jon for the starting code and everyone else for their input. here is how it looks now:
[code]Option Explicit
Function OnClick(ByRef clickData)
' Current Timestamp function to format YYYYMMDDHHMMSS
Dim timeStamp, timeStamp24Year, timeStamp24Month, timeStamp24Day, timeStamp24Hour, timeStamp24Minute, timeStamp24Second, timeStampFormatted
timeStamp = now()
timeStamp24Year = (Year(timeStamp))
timeStamp24Month = (Month(timeStamp))
If (timeStamp24Month < 10) Then
timeStamp24Month = "0" & timeStamp24Month
End If
timeStamp24Day = (Day(timeStamp))
If (timeStamp24Day < 10) Then
timeStamp24Day = "0" & timeStamp24Day
End If
timeStamp24Hour = (Hour(timeStamp))
If (timeStamp24Hour < 10) Then
timeStamp24Hour = "0" & timeStamp24Hour
End If
timeStamp24Minute = (Minute(timeStamp))
If (timeStamp24Minute < 10) Then
timeStamp24Minute = "0" & timeStamp24Minute
End If
timeStamp24Second = (Second(timeStamp))
If (timeStamp24Second < 10) Then
timeStamp24Second = "0" & timeStamp24Second
End If
timeStampFormatted = timeStamp24Year & timeStamp24Month & timeStamp24Day & timeStamp24Hour & timeStamp24Minute & timeStamp24Second
' Selected files
Dim file, files
Set files = clickData.func.sourcetab.selected_files
For Each file in files
Dim fileName, createdDate, modifiedDate
fileName = file.name
createdDate = file.create.Format("D#yyyyMMdd_T#HHmmss")
modifiedDate = file.modify.Format("D#yyyyMMdd_T#HHmmss")
Dim desc, tag
desc = timeStampFormatted & " - not image file"
tag = "recorded on " & timeStampFormatted & " - name: " & fileName & ", created: " & createdDate & " , modified: " & modifiedDate
' If image file
if file.metadata = "image" Then
Dim imgTaken, imgTaken24Year, imgTaken24Month, imgTaken24Day, imgTaken24Hour, imgTaken24Minute, imgTaken24Second, imgTakenFormated
imgTaken = file.metadata.image.datetaken
imgTaken24Year = (Year(imgTaken))
imgTaken24Month = (Month(imgTaken))
If (imgTaken24Month < 10) Then
imgTaken24Month = "0" & imgTaken24Month
End If
imgTaken24Day = (Day(imgTaken))
If (imgTaken24Day < 10) Then
imgTaken24Day = "0" & imgTaken24Day
End If
imgTaken24Hour = (Hour(imgTaken))
If (imgTaken24Hour < 10) Then
imgTaken24Hour = "0" & imgTaken24Hour
End If
imgTaken24Minute = (Minute(imgTaken))
If (imgTaken24Minute < 10) Then
imgTaken24Minute = "0" & imgTaken24Minute
End If
imgTaken24Second = (Second(imgTaken))
If (imgTaken24Second < 10) Then
imgTaken24Second = "0" & imgTaken24Second
End If
imgTakenFormated = imgTaken24Year & imgTaken24Month & imgTaken24Day & "_" & imgTaken24Hour & imgTaken24Minute &imgTaken24Second
desc = timeStampFormatted & " - image file"
tag = "recorded on " & timeStampFormatted & " - name: " & fileName & ", created: " & createdDate & " , modified: " & modifiedDate & " , taken: " & imgTakenFormated
end if
clickData.func.command.ClearFiles
clickData.func.command.AddFile file
clickData.func.command.RunCommand "SetAttr META ""comment:" & desc & """"
clickData.func.command.RunCommand "SetAttr META ""tags: +" & +tag & """"
Next
End Function
[/code]
Although it works now, it was really fun working on it and looking to make some improvements. Mainly, I'm sure there must be a way to reuse the part where I broke up a date variable into 6 parts and put it back together. I think I may need to learn how to make a function out of that so that I can do something like "(someDate.myformatFunction(yyyyMMdd_HHmmss)" in the future if I want to format other date fields. So if anyone has any feedback on that or other comments about jiant mistakes I made above, please let me know.
Thanks!!