Finder中的Applescript:前进到下一个文件

时间:2009-07-05 19:58:47

标签: scripting file applescript osx-leopard finder

我要做的是:

将x设置为当前选择,然后将选择前进到下一个文件,然后删除x。

我这样做是因为CMD-backspace每次都清除选择,这很烦人!

2 个答案:

答案 0 :(得分:1)

我有点困惑。当您说“下一个文件”时,您指的是选择中的下一个文件,或整个文件夹中的下一个文件?我会给你们两个。

选择

tell application "Finder"
    set x to (get the selection) as list
    repeat with i from 1 to the count of x
        set this_item to item i of x
        delete this_item
    end repeat
end tell

整个文件夹

tell application "Finder"
    set these_windows to (get every window) as list
    if these_windows is {} then --no windows are open, refer to the desktop
        set these_items to (get every item of desktop) as list
        repeat with i from 1 to the count of these_items
            set this_item to item i of these_items
            delete this_item
        end repeat
    else --a window is open 
        set this_folder to the target of window 1
        set these_items to the (entire contents of this_folder) as list
        repeat with i from 1 to the count of these_items
            set this_item to item i of these_items
            delete this_item
        end repeat
    end if
end tell

答案 1 :(得分:0)

您可以告诉系统事件为密钥编写脚本,例如按下向下箭头,然后按命令⌘ + delete

删除