Передача элемента из Automator в AppleScript в рабочем процессе - PullRequest
0 голосов
/ 14 января 2020

У меня есть рабочий процесс Automator, который спрашивает:

«Запросить элементы поиска» «Запустить сценарий Apple»

Проблема в том, что я не могу получить элементы, которые были выбраны для используется в моем Apple Script.

    set display_text to "Please enter your password:"
repeat
    considering case
        set init_pass to text returned of (display dialog display_text default answer "" with hidden answer)
        set final_pass to text returned of (display dialog "Please verify your password below." buttons {"OK"} default button 1 default answer "" with hidden answer)
        if (final_pass = init_pass) then
            exit repeat
        else
            set display_text to "Mismatching passwords, please try again"
        end if
    end considering
end repeat

tell application "Finder"
    #set theItems to choose folder with prompt "Please select a document to process:"
    #set theItems to selected
    set theItem to selection # This is where the problem is.
    set theItem to (item 1 of theItems) as alias
    set itemPath to quoted form of POSIX path of theItem
    set fileName to name of theItem
    set theFolder to POSIX path of (container of theItem as alias)
    set zipFile to quoted form of (fileName & ".zip")
    do shell script "cd '" & theFolder & "'; zip -x .DS_Store -r0 -P '" & final_pass & "' " & zipFile & " ./'" & fileName & "'"
end tell

1 Ответ

0 голосов
/ 14 января 2020

Когда вы добавите действие Run AppleScript, вы заметите, если он поставляется с кодом по умолчанию, начиная с on run {input, parameters}. Input - это переменная, которая содержит результаты последнего действия: в этом случае Get Selected Finder Items возвращает список псевдонимов, поэтому вы можете получить к ним доступ следующим образом:

automator screenshot

Легко, peasy ...

...