applescript 掉落物品列表显示不正确
applescript list of droppeditems not displaying properly
我有以下代码:
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 个带有第一个的路径文件,然后是第二个文件的路径。我错过了什么?
谢谢!
我认为这个简化版更符合您的要求?
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
我有以下代码:
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 个带有第一个的路径文件,然后是第二个文件的路径。我错过了什么?
谢谢!
我认为这个简化版更符合您的要求?
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