Based on some good feedback in other threads from jon, leo, and tbone, I improved the script a little more. I use the log panel to print a preview of changes and then paste them into excel to easily sort and review. Also, it's a great way to save for backup before making updates (goo.gl/ld1HVx)
Option Explicit
Function OnClick(ByRef clickData)
Dim file, files, countFiles, countUpdate ,countSkip, countReview, liveStatus
Set files = clickData.func.sourcetab.selected_files
countFiles = 0
countUpdate = 0
countSkip = 0
countReview = 0
liveStatus = Empty
If (InStr(clickData.func.qualifiers, "shift") > 0) Then
liveStatus = " - SHIFT held during operation: All Chnages are LIVE"
End If
DOpus.OutputString "Number; File Name; File Name Date; Modified Date; Date Taken; Date Digitized; File Type; Status; Reason"
For Each file in files
Dim fileName, fileType, modifiedDate, imgTaken, imgDigitized, regex0, fileNameDate, metaString
countFiles = countFiles + 1
fileName = file.name
fileType = file.metadata
fileNameDate = Empty
imgTaken = Empty
imgDigitized = Empty
modifiedDate = file.modify.Format("D#yyyyMMdd T#HH:mm:ss")
Set regex0 = new RegExp
regex0.Pattern = ".*(20[0-2][0-9])\D?([0-1][0-9])\D?([0-3][0-9])\D?([0-2][0-9])\D?([0-5][0-9])\D?([0-5][0-9]).*"
If (regex0.Test(fileName)) Then
fileNameDate = regex0.Replace(fileName, "$1$2$3 $4:$5:$6")
End If
If file.metadata = "image" Then
imgTaken = file.metadata.image.datetaken
If (Not IsEmpty(imgTaken)) Then
imgTaken = DOpus.Create.Date(imgTaken).Format("D#yyyyMMdd T#HH:mm:ss")
End If
imgDigitized = file.metadata.image.datedigitized
If (Not IsEmpty(imgDigitized)) Then
imgDigitized = DOpus.Create.Date(imgDigitized).Format("D#yyyyMMdd T#HH:mm:ss")
End If
End if
If file.metadata = "image" Then
If (Not IsEmpty(fileNameDate)) Then
If (IsEmpty(imgTaken)) Then
If (IsEmpty(imgDigitized)) Then
metaString = fileName & "; " & fileNameDate & "; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "- ; " & fileType
If (fileNameDate <= modifiedDate) Then
'Image, YES File_Name_Date, NO Image_Taken, NO Image_Digitized, File_Name_Date <= Modified_Date - Update Image_Taken, Image_Digitized, and Modified_Date with File_Name_Date - Update
DOpus.OutputString countFiles & "; " & metaString & "; Update; 1"
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:" & fileNameDate & """" & " " & """datedigitized:" & fileNameDate & """" & " " & """lastmodifieddate:" & fileNameDate & """"
End If
Else
'Image, YES File_Name_Date, NO Date_Taken, NO Date_Digitized, File_Name_Date > Modified_Date - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 2"
countReview = countReview + 1
End if
Else
metaString = fileName & "; " & fileNameDate & "; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "; " & fileType
'Image, YES File_Name_Date, NO Date_Taken, YES Date_Digitized - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 3"
countReview = countReview + 1
End if
Elseif (Not IsEmpty(imgDigitized)) Then
metaString = fileName & "; " & fileNameDate & "; " & modifiedDate & "; " & imgTaken & "; " & imgDigitized & "; " & fileType
'Image, YES File_Name_Date, YES Date_Taken, YES Date_Digitized - Skip
DOpus.OutputString countFiles & "; " & metaString & "; Skip; 4"
countSkip = countSkip + 1
Else
metaString = fileName & "; " & fileNameDate & "; " & modifiedDate & "; " & imgTaken & "; " & imgDigitized & "- ; " & fileType
'Image, YES File_Name_Date, YES Date_Taken, NO Date_Digitized - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 5"
countReview = countReview + 1
End if
Else
If (IsEmpty(imgTaken)) Then
If (IsEmpty(imgDigitized)) Then
metaString = fileName & "; " & fileNameDate & "- ; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "- ; " & fileType
'Image, NO File_Name_Date, NO Date_Taken, NO Date_Digitized - Update Date_Taken, Date_Digitized with Modified_Date - Update
DOpus.OutputString countFiles & "; " & metaString & "; Update; 6"
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:" & modifiedDate & """" & " " & """datedigitized:" & modifiedDate & """"
clickData.func.command.RunCommand "SetAttr META datetaken:lastmodifieddate datedigitized:lastmodifieddate"
'clickData.func.command.RunCommand "SetAttr META datetaken:lastmodifieddate"
End If
Else
metaString = fileName & "; " & fileNameDate & "- ; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "; " & fileType
'Image, NO File_Name_Date, NO Date_Taken, YES Date_Digitized - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 7"
countReview = countReview + 1
End if
Elseif (Not IsEmpty(imgDigitized)) Then
metaString = fileName & "; " & fileNameDate & "- ; " & modifiedDate & "; " & imgTaken & "; " & imgDigitized & "; " & fileType
'Image, NO File_Name_Date, YES Date_Taken, YES Date_Digitized - Skip
DOpus.OutputString countFiles & "; " & metaString & "; Skip; 8"
countSkip = countSkip + 1
Else
metaString = fileName & "; " & fileNameDate & "- ; " & modifiedDate & "; " & imgTaken & "; " & imgDigitized & "- ; " & fileType
'Image, NO File_Name_Date, YES Date_Taken, NO Date_Digitized - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 9"
countReview = countReview + 1
End if
End if
Else
If (Not IsEmpty(fileNameDate)) Then
metaString = fileName & "; " & fileNameDate & "; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "- ; " & fileType
If (fileNameDate < modifiedDate) Then
'Other, YES File_Name_Date, File_Name_Date < Modified_Date - Update Modified_Date with File_Name_Date
DOpus.OutputString countFiles & "; " & metaString & "; Update; 10"
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 " & """lastmodifieddate:" & fileNameDate & """"
End If
Elseif (fileNameDate = modifiedDate) Then
'Other, YES File_Name_Date, File_Name_Date = Modified_Date - Skip
DOpus.OutputString countFiles & "; " & metaString & "; Skip; 11"
countSkip = countSkip + 1
Else
'Other, YES File_Name_Date, File_Name_Date > Modified_Date - Review
DOpus.OutputString countFiles & "; " & metaString & "; Review; 12"
countReview = countReview + 1
End if
Else
metaString = fileName & "; " & fileNameDate & "- ; " & modifiedDate & "; " & imgTaken & "- ; " & imgDigitized & "- ; " & fileType
'Other, NO File_Name_Date, Retain Modified_Date - Skip
DOpus.OutputString countFiles & "; " & metaString & "; Skip; 13"
countSkip = countSkip + 1
End if
End if
Next
DOpus.OutputString "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
DOpus.OutputString "Total Files: (" & countFiles & ") - Update: (" & countUpdate & "), Skip: (" & countSkip & "), Need Review: (" & countReview & ")" & liveStatus
End Function