我找到了下面的教程,介绍如何编写自动化脚本来获取查找器窗口的当前路径。我想让它更加健壮并对其进行修改,以便它根据所选内容的条件获取以下路径。那可能吗?如果是的话怎么办?
try
tell application "Finder" to set the clipboard to POSIX path of (target of window 1 as alias)
on error
beep
end try
https://apple.stackexchange.com/questions/47216/copying-the-current-directorys-path-to-the-clipboard
当前代码仅复制目录路径
第四种情况:没有选择任何内容,也没有 Finder 窗口。 并且也可能存在多个 Finder 窗口。
涵盖所有情况的逻辑如下:
tell application "Finder"
set selectedItems to selection
if selectedItems is not {} then
set the clipboard to POSIX path of (item 1 of selectedItems as alias)
else if exists window 1 then
set the clipboard to POSIX path of (target of window 1 as alias)
end if
end tell