macOS Sequoia - 写真のサムネイル画面で作成日表示が正しくない
Mac OS をSequoiaに変えてから起こったことです.
* タイトルを変更しました。 Apple Inc.
Mac mini, macOS 15.0
Mac OS をSequoiaに変えてから起こったことです.
* タイトルを変更しました。 Apple Inc.
Mac mini, macOS 15.0
コードをベタベタ貼るもどうかと思いましたが、需要が多そうなのでポストしますね。
以下は EXIF 情報の DataTimeOriginal を取得して、ファイルの作成日と変更日をセットする AppleScript です。
exiftool コマンドを使わない方法です。
作り方: スクリプトエディタに下記のコードをコピペして保存
使い方: スクリプトエディタから実行
# コード
use AppleScript version "2.7"
use scripting additions
use framework "Cocoa"
property OSX : current application
property nil : missing value
on run
set uti to "public.jpeg"
set msg to "JPEG ファイルを選択してください (複数選択できます)"
set args to choose file of type uti with prompt msg with multiple selections allowed
repeat with f in args
set filemanager to OSX's NSFileManager's defaultManager()
set fpath to f's POSIX path
set odate to get_odate(fpath)
if odate is not nil then
set new_attrs to {NSFileCreationDate:odate, NSFileModificationDate:odate}
set {res, err} to (filemanager's setAttributes:new_attrs ofItemAtPath:fpath |error|:(reference))
if not res then
error err's localizedDescription() as text
end if
end if
end repeat
end run
on get_odate(fpath)
set odate to nil
set rep to OSX's NSBitmapImageRep's imageRepWithContentsOfFile:fpath
if rep is not nil then
set exif to rep's valueForProperty:"NSImageEXIFData"
if exif is not nil then
set odate to exif's objectForKey:"DateTimeOriginal"
end if
end if
if odate is not nil then
set df to OSX's NSDateFormatter's alloc()'s init()
set df's locale to OSX's NSLocale's localeWithLocaleIdentifier:"en_US_POSIX"
set df's dateFormat to "yyyy:MM:dd HH:mm:ss"
set odate to (df's dateFromString:odate)
end if
return odate
end get_odate
Sequoia以前のOSで正しく表示されていたのはなぜでしょうか.
追記
「指定された Finder 項目を取得」で複数のファイルを指定できますが、「結果」のところは最後の結果だけが表示されます。ワークフローのテストの際はファイルを一枚でトライしてみてください。
>作成日(最初にicloud写真システムに取り込まれた日)と撮影日が一致するのでは?
なるほど、そうかもしれません。
>特別なことをしなければ、普通のosがファイルを管理するときの振る舞い
Lightroomで書き出しした場合についてですが、
形式変換して書き出した場合は新しいファイルが作成されるのでFinderで表示される「作成日」が書き出し日時になるのですが、
オリジナルで書き出した場合はFinderで表示される「作成日」は変更されません。(Lightroomが読み込んだ日時のまま)
前者は新規ファイル作成、後者はファイルコピーなのでこれがOSの仕様によるふるまいということになるのでしょう。
macOS Sequoia - 写真のサムネイル画面で作成日表示が正しくない