Вернуть результаты из нескольких списков выбора в Applescript - PullRequest
0 голосов
/ 28 сентября 2018

Этот сценарий предназначен для использования в 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

Ответы [ 2 ]

0 голосов
/ 28 сентября 2018

Я включил весь рабочий сценарий ниже на тот случай, если кто-то ищет что-то подобное.«-Sep» является частью exiftool и разбивает строку в зависимости от того, что вы положили после него.Мне пришлось скрыть его для строки сценария оболочки, но он обычно не имеет обратной косой черты.

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
0 голосов
/ 28 сентября 2018

Вы ограничиваете список одним элементом в этой строке

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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...