яблочный список не отображаемых должным образом элементов - PullRequest
0 голосов
/ 03 декабря 2018

У меня есть следующий код:

on open theDroppedItems
    set PosixList to {}
    repeat with a from 1 to length of theDroppedItems
        set theCurrentDroppedItem to item a of theDroppedItems
        set PosixPath to convertPathToPOSIXString(theCurrentDroppedItem)
        copy PosixPath to the end of the PosixList
    end repeat
    display dialog convertListToString(PosixList, space)
end open

on convertPathToPOSIXString(thePath)
    tell application "System Events"
        try
            set thePath to path of disk item (thePath as string)
        on error
            set thePath to path of thePath
        end try
    end tell
    return POSIX path of thePath
end convertPathToPOSIXString

on convertListToString(theList, theDelimiter)
    set AppleScript's text item delimiters to theDelimiter
    set theString to theList as string
    set AppleScript's text item delimiters to ""
    return theString
end convertListToString

Я ожидаю, что он позволит мне перетащить файл на appleScript (сохраненный как приложение) и отобразить список, похожий на /Users/adam/a.txt /users/adam/b.txt, однако он даетМне 2 диалогов, 1 с путем к первому файлу, затем второй с путем ко второму файлу.Чего мне не хватает?

спасибо!

1 Ответ

0 голосов
/ 03 декабря 2018

Я думаю, что эта сокращенная версия больше соответствует тому, что вы ищете?

on open theDroppedItems
    set posixList to {}
    repeat with a from 1 to length of theDroppedItems
        set theCurrentDroppedItem to item a of theDroppedItems
        set posixPath to POSIX path of theCurrentDroppedItem
        set end of posixList to (posixPath & linefeed & linefeed)
    end repeat
    display dialog posixList as string
end open
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...