此脚本用于Capture One,其中我将人们的名字分配给EXIF数据。
我正在尝试返回列表的结果,该列表可能是用户做出的一个或多个选择。我可以使用列表中的项目1使其正常工作,但我不知道如何处理从列表中任何位置选择2个或更多名称的人?
感谢您提供的任何帮助。
tell application "Capture One 11"
set peopleChoices to {"Abbie", "Charlie", "De-Arne", "Dean", "Jason", "Marlene", "Peta ", "Phoenix", "Rod", "Vanessa", "Yvonne"}
set peopleList to choose from list peopleChoices with prompt "Select your keyword/s:" with multiple selections allowed
if the result is not false then
set exif_keywords to item 1 of the result
end if
set selectedVariants to get selected variants
repeat with i from 1 to number of items in selectedVariants
set this_item to item i of selectedVariants
set theID to id of (parent image of this_item)
do shell script "/usr/local/bin/exiftool -Subject='" & exif_keywords & "' -m -overwrite_original_in_place " & quoted form of theID
reload metadata this_item
end repeat
display dialog "EXIF data has been updated"
end tell
答案 0 :(得分:1)
您将列表限制为这一行中的一项
set exif_keywords to item 1 of the result
只需将其更改为
set exif_keywords to result
我不知道应该如何在exiftool
行中传递关键字,您可以使用text item delimiters
来使列表变平,本示例将列表逗号分隔开。如果参数必须用空格分隔,请用","
替换space
。
set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
set exif_keywords to exif_keywords as text
set AppleScript's text item delimiters to ASTID
答案 1 :(得分:0)
如果其他人正在寻找类似的内容,我将下面的整个工作脚本包括在内。 “ -sep”是exiftool的一部分,根据您放置在字符串后的内容来分割字符串。我不得不在shell脚本行中对其进行转义,但是它几乎没有反斜杠。
tell application "Capture One 11"
set peopleChoices to {"Abbie", "Charlie", "De-Arne", "Dean", "Jason", "Marlene", "Peta", "Phoenix", "Rod", "Vanessa", "Yvonne"}
set peopleList to choose from list peopleChoices with prompt "Select your keyword:" with multiple selections allowed
if the result is not false then
set exif_keywords to result
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
set exif_keywords to exif_keywords as text
set AppleScript's text item delimiters to TID
end if
set selectedVariants to get selected variants
repeat with i from 1 to number of items in selectedVariants
set this_item to item i of selectedVariants
set theID to id of (parent image of this_item)
do shell script "/usr/local/bin/exiftool -sep \",\" -Keywords='" & exif_keywords & "' -m -overwrite_original_in_place " & quoted form of theID
reload metadata this_item
end repeat
display dialog "EXIF data has been updated"
end tell