I am updating the date taken of files and would like to output to log the original Date taken before updating and the updated version. But after running the SetAttr command to change the date, I try pulling Date Taken again which only gives me results of Original Date Taken not new.
Ex:
imgTaken = file.metadata.image.datetaken
clickData.func.command.RunCommand "SetAttr META datetaken:+0:00:10"
imgTakenNew = file.metadata.image.datetaken
imgTaken and imgTaken New always give same results even though the date has changed. I also tried adding the ClearFiles and AddFiles command before checking for updated date thinking that it will refresh the file info but that did not work.
Here is the full Script:
[code]Option Explicit
Function OnClick(ByRef clickData)
Dim file, files, countFiles, countUpdate ,countSkip, countReview, liveStatus, dateShift
Set files = clickData.func.sourcetab.selected_files
countFiles = 0
countUpdate = 0
countSkip = 0
countReview = 0
liveStatus = Empty
dateShift = "+0:00:10"
If (InStr(clickData.func.qualifiers, "shift") > 0) Then
liveStatus = " - SHIFT held during operation: All Changes are LIVE"
End If
DOpus.OutputString "Number; File Name; Date Taken; Date Taken New ;Date Digitized; Date Digitized New; Status; Reason"
For Each file in files
Dim fileName, fileType, modifiedDate, imgTaken, imgDigitized, imgTakenNew, imgDigitizedNew
countFiles = countFiles + 1
fileName = file.name
fileType = file.metadata
imgTaken = Empty
imgDigitized = Empty
imgTakenNew = Empty
imgDigitizedNew = Empty
If (file.metadata = "image") Then
imgTaken = file.metadata.image.datetaken
imgDigitized = file.metadata.image.datedigitized
If (imgTaken <> Empty AND imgDigitized <> Empty) Then
countUpdate = countUpdate + 1
If (InStr(clickData.func.qualifiers, "shift") > 0) Then
clickData.func.command.ClearFiles
clickData.func.command.AddFile file
clickData.func.command.RunCommand "SetAttr META " & """datetaken:" & dateShift & """" & " " & """datedigitized:" & dateShift & """" & " " & """lastmodifieddate:" & dateShift & """"
End If
clickData.func.command.ClearFiles
clickData.func.command.AddFile file
imgTakenNew = file.metadata.image.datetaken
imgDigitizedNew = file.metadata.image.datedigitized
DOpus.OutputString countFiles & "; " & fileName & "; " & imgTaken & "; " & imgTakenNew & "; " & imgDigitized & "; " & imgDigitizedNew & "; Update; 1"
Else
'Image does not contain Date Taken and/or Date Digitized
DOpus.OutputString countFiles & "; " & fileName & "; " & imgTaken & "; " & imgTakenNew & "; " & imgDigitized & "; " & imgDigitizedNew & "; Review; 2"
countReview = countReview + 1
End If
Else
'Not an image - Skip
DOpus.OutputString countFiles & "; " & fileName & "; " & imgTaken & "; " & imgTakenNew & "; " & imgDigitized & "; " & imgDigitizedNew & "; Skip; 3"
countSkip = countSkip + 1
End If
Next
DOpus.OutputString "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
DOpus.OutputString "Total Files: (" & countFiles & ") - Update: (" & countUpdate & "), Skip: (" & countSkip & "), Need Review: (" & countReview & ")" & liveStatus
End Function[/code]