What I'm trying to do is:
我想要做的是:
set x to current selection, then advance the selection to the next file and then delete x.
将x设置为当前选择,然后将选择前进到下一个文件,然后删除x。
I'm doing this because CMD-backspace clears the selection every time and that's annoying!
我这样做是因为CMD-backspace每次都清除选择,这很烦人!
2 个解决方案
#1
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
#2
You could tell system events to script the keys, such as push the down arrow, then delete by Command ⌘ + delete
您可以告诉系统事件为密钥编写脚本,例如按下向下箭头,然后按命令⌘+ delete删除
#1
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
#2
You could tell system events to script the keys, such as push the down arrow, then delete by Command ⌘ + delete
您可以告诉系统事件为密钥编写脚本,例如按下向下箭头,然后按命令⌘+ delete删除