Date AppleScript:创建日期对象时出错-1728
我试图从一批图像中获取图像日期,并将该图像日期粘贴到另一批具有相同文件名但不同文件类型的图像中 我在这里找到了一个帮助我的AppleScript: 然而,日期部分很棘手 在导出部分,我通常解析出日期,但导入部分不起作用Date AppleScript:创建日期对象时出错-1728,date,applescript,Date,Applescript,我试图从一批图像中获取图像日期,并将该图像日期粘贴到另一批具有相同文件名但不同文件类型的图像中 我在这里找到了一个帮助我的AppleScript: 然而,日期部分很棘手 在导出部分,我通常解析出日期,但导入部分不起作用 if (curTagShort is "ImageDate") then log "-- try to set the date --" -- set curDate to (curVal as date)
if (curTagShort is "ImageDate") then
log "-- try to set the date --"
-- set curDate to (curVal as date)
set curDate to rich text of (item ctr of theList)
log (curVal as string)
adjust image date (date curVal as string) of images {curImg}
else
上述代码生成以下日志:
(*-- try to set the date --*)
(*Freitag, 26. September 2014 20:21:21*)
get date "Freitag, 26. September 2014 20:21:21" of image version id "CeT8CoCwSYuhejftq9kmag"
--> error number -1728 from date "Freitag, 26. September 2014 20:21:21" of image version id "CeT8CoCwSYuhejftq9kmag"
(*date "Freitag, 26. September 2014 20:21:21" of item 1 of {«class rkdp» id "CeT8CoCwSYuhejftq9kmag" of application "Aperture"} kann nicht in Typ string umgewandelt werden.*)
可变曲线是
set curVal to item ctr of theList
ctr是当前索引,列表是一个列表。。。很明显
到目前为止,对于非工作部分,如果我将>>curVal替换为string,请不要将日期对象强制为字符串。日期对象有一个名为“日期字符串”的属性,您可以使用它 而不是这样做:
date curVal as string
…这样做:
date string of date curVal
请在AppleScript编辑器中单独尝试此示例脚本,以使其更清晰:
set theDate to the current date
set theDateString to the date string of theDate
set theTimeString to the time string of theDate
set theDateTimeString to theDateString & space & theTimeString
return theDateTimeString
在AppleScript编辑器窗口底部的结果窗格中,您将看到此脚本以字符串形式返回当前日期和时间,如下所示:
"Sunday, September 28, 2014 09:11:36"
ctr是当前索引,列表是一个列表。。。很明显
如果你必须解释你的变量名,那么他们的名字就很糟糕。我建议您将“ctr”重命名为“theCurrentIndex”,无论“theList”是什么,都要指定它。例如:“thePhotoList.”或者您可以在列表中使用复数名称,例如“thePhotos”,因为这样您就可以说“在照片中重复thePhoto”
"Sunday, September 28, 2014 09:11:36"