从AppleScript获取文件路径

时间:2012-10-30 14:10:48

标签: applescript

我需要从AppleScript获取所选文件夹的文件路径。我使用以下代码来执行此操作。

    --Display selection window
    set source_folder to choose folder with prompt "Please select directory."
    --Get the path of the folder
    set item_list to get the path of every disk item of source_folder

我得到的文件路径如下:

文件:路径:到:所述:fodler

我想要的是:

文件/路径/到/与/文件夹

2 个答案:

答案 0 :(得分:3)

尝试获取POSIX路径:

set item_list to get the POSIX path of every disk item of source_folder

答案 1 :(得分:3)

尝试:

set source_folder to choose folder with prompt "Please select directory."

tell application "System Events"
    set item_list to POSIX path of every disk item of source_folder
end tell