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

发布于 2024-07-26 02:30:45 字数 102 浏览 15 评论 0原文

我想做的是:

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

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

What I'm trying to do is:

set x to current selection, then advance the selection to the next file and then delete x.

I'm doing this because CMD-backspace clears the selection every time and that's annoying!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏别ゝ 2024-08-02 02:30:45

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

选择

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

I'm a bit confused. When you say 'next file' are you referring to the next file in the selection, or the next file in the whole folder? I'll give you both.

Selection

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

Entire folder

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
嘿哥们儿 2024-08-02 02:30:45

您可以告诉系统事件对按键进行脚本化,例如按下向下箭头,然后通过 Command ⌘ + delete 删除

You could tell system events to script the keys, such as push the down arrow, then delete by Command ⌘ + delete

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文