我想发出终端命令(调用AppleScript很好)以在当前空间的Finder窗口中打开路径。
如果路径是在另一个空间的Finder中打开的,则我不想切换到该空间或将那个finder窗口移到当前空间。如果该路径已在当前空间的Finder窗口中打开,则专注于该路径或向其打开新的Finder窗口都可以。
我运行了很多为不同任务设置的空间,并且我不想从可能正在使用的Finder窗口或任何其他空间中删除Finder窗口。
例如,在Applescript中,打开“应用程序”文件夹:-
tell application "Finder"
make new Finder window to folder "Applications" of startup disk
end tell
您可以将其另存为脚本,并使用osascript命令从命令行调用它,也可以使用osascript的-e参数直接执行它:-
osascript -e 'tell application "Finder" to make new Finder window to folder "Applications" of startup disk'
如果您想打开一个特定路径,而不是一个命名文件夹,则可以使用以下路径引用该路径:
POSIX file "/some/directory/path"
因此,完整的脚本应为:-
tell application "Finder"
activate
make new Finder window to (POSIX file "/some/directory/path")
end tell
注意:该activate
命令将“查找器”窗口聚焦,这是可选的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句