カメラの日時設定を誤って撮影してしまったり、2台以上のカメラを撮影時刻で合わせたい時などに、相対的に時刻を変更するスクリプト。
別途 ExifTool のインストールと Developer Tools のインストールが必要。(
作成日を変更しなくてもよいなら、「--ここから作成日変更」の行から「do shell script scrptCDW」の行までを削除し、Developer Toolsのインストールも不必要。)
ExifToolが対応していればRAWファイルも変更可能。
tell application "Finder"
set objs to files of (choose folder)
end tell
activate
display dialog "増減" buttons {"+", "-"} default button "+"
set crease to button returned of result
set modY to text returned of (display dialog "シフトする「年」を入力" default answer 0)
set modM to text returned of (display dialog "シフトする「月」を入力" default answer 0)
set modD to text returned of (display dialog "シフトする「日」を入力" default answer 0)
set modH to text returned of (display dialog "シフトする「時」を入力" default answer 0)
set modMin to text returned of (display dialog "シフトする「分」を入力" default answer 0)
set modS to text returned of (display dialog "シフトする「秒」を入力" default answer 0)
set offsetTime to "'" & modY & ":" & modM & ":" & modD & " " & modH & ":" & modMin & ":" & modS & "'"
log offsetTime
repeat with obj in objs
set objPOSIX to quoted form of the POSIX path of (obj as alias)
set scrptDT to "exiftool -overwrite_original_in_place -DateTimeOriginal" & crease & "=" & offsetTime & " " & "-createdate" & crease & "=" & offsetTime & " " & objPOSIX --オリジナルをリネームして残す場合は -overwrite_original_in_placeを削除
log scrptDT
do shell script scrptDT
--ここから作成日変更
set scrptCDR to "exiftool -CreateDate" & " " & objPOSIX
log scrptCDR
do shell script scrptCDR
set CDR to result
set AppleScript's text item delimiters to ":"
set CDRList to text items of CDR
set yy to item 2 of CDRList --年取得
set AppleScript's text item delimiters to space
set yy to item 2 of text items of yy
set mm to item 3 of CDRList --月取得
set dd to item 4 of CDRList --日取得
set AppleScript's text item delimiters to space
set dd to item 1 of text items of dd
set H to item 4 of CDRList --時取得
set AppleScript's text item delimiters to space
set H to item 2 of text items of H
set M to item 5 of CDRList --分取得
set S to item 6 of CDRList --秒取得
set scrptCDW to "/Developer/Tools/SetFile -d " & "'" & mm & "/" & dd & "/" & yy & " " & H & ":" & M & ":" & S & "'" & " " & objPOSIX
log scrptCDW
do shell script scrptCDW
end repeat