Applescript:将选择(文件夹)复制到桌面并将文件夹移动到其他位置

时间:2015-07-16 19:10:19

标签: variables applescript directory

首先,我是一个苹果菜noob ;-)我要求的是简单但我不可能执行。请参阅下面的脚本。

tell application "Finder"
    set selected_items to selection
    set the defaultPath to path to desktop folder as alias
    duplicate selection to defaultPath

    --I want to take take selection variable that is duplicated to the desktop and move that folder icon to the bottom of my screen.
    set desktop position of selection to {1400, 1200}
end tell

Here is the error I get ----> error "Finder got an error: Can’t set desktop position of selection to {1400, 1200}." number -10006 from desktop position of selection

在这个例子中,我有一个名为“12345_SomeFile”的文件夹作为选择。我希望能够使用选择变量来执行其他操作,例如移动,打开和将窗口移动到特定位置。希望这是有道理的。

非常感谢任何帮助,并提前感谢您。

1 个答案:

答案 0 :(得分:0)

selection会返回所选项目的列表,因此我假设您要复制所选项目的第一项。 我还假设桌面的设置sorted by设置为无

tell application "Finder"
    set selected_items to selection
    if selected_items is not {} then
        set newItem to duplicate item 1 of selected_items to desktop
        set desktop position of newItem to {1400, 1200}
    end if
end tell