返回Applescript中多个列表选择的结果

问题描述 投票:0回答:2

此脚本用于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
applescript
2个回答
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

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
© www.soinside.com 2019 - 2024. All rights reserved.