Macos 如何获得图像';s(jpeg,原始)使用AppleScript捕获日期时间?
到现在为止,我只能得到比捕获日期晚几秒的图像文件创建日期。如何从Exif获取图像的捕获日期Macos 如何获得图像';s(jpeg,原始)使用AppleScript捕获日期时间?,macos,applescript,exif,capture,Macos,Applescript,Exif,Capture,到现在为止,我只能得到比捕获日期晚几秒的图像文件创建日期。如何从Exif获取图像的捕获日期 tell application "Finder" try set the source_folder to (folder of the front window) as text on error -- no open folder windows set the source_folder to (path to desktop folder) as
tell application "Finder"
try
set the source_folder to (folder of the front window) as text
on error -- no open folder windows
set the source_folder to (path to desktop folder) as text
end try
set these_items to the selection
end tell
set repeatCount to 1
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items) as alias
set this_info to info for this_item
set {file_name, file_ext} to splitExtension from the name of this_info
set capture_date to (the creation date of this_info)
set formatted_date to (my dateFormat(capture_date))
set new_name to formatted_date & file_ext
-- check to see if it's already there
tell application "Finder"
if (exists item (source_folder & new_name)) then
--- display dialog new_name & " already exists."
set new_name to formatted_date & "_" & repeatCount & file_ext
set name of this_item to new_name
set repeatCount to 1 + repeatCount
else
set name of this_item to new_name
end if
end tell
end repeat
您可以在AppleScriptObjC和AppKit的帮助下获取EXIF数据 结果是一个包含数据的Applescript记录,捕获日期可能是键
dateTimeDigitalized
的值,它是一个字符串
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "AppKit"
set theFile to (choose file)
set imageRep to current application's NSBitmapImageRep's imageRepWithContentsOfFile:(POSIX path of theFile)
set exifData to imageRep's valueForProperty:(current application's NSImageEXIFData)
if exifData is missing value then
display dialog "No EXIF data found" buttons "Cancel" default button 1
else
set exifData to exifData as record
set captureDate to DateTimeDigitized of exifData
end if
还有
DateTimeOriginal
,可能与datetimedigitalized
@vadian相同,谢谢。它可以工作,但是日期格式是这样的:2018/08/17 13/12/04.JPG,如何去掉斜杠?我可以在获取之前定义日期格式吗?@vadian ooh,斜杠应该是“:”这是文件名中允许的,Mac会自动将其显示为“/”。现在我用将AppleScript的文本项分隔符设置为“/”