为什么这样做:
tell application "Finder"
activate
reveal POSIX file ("/Users/Torben/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/file.png")
end tell
...但不是这个
tell application "Finder"
activate
reveal POSIX file ("/Users/Torben/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/" & "file.png")
end tell
如果我想将路径(字符串)与变量(字符串)连接起来,如何使它工作?
答案 0 :(得分:0)
我建议使用相对的HFS路径。第一行指向当前用户的library
文件夹。
set libraryFolder to path to library folder from user domain as text
tell application "Finder"
reveal file (libraryFolder & "com~apple~CloudDocs:MyFolder:" & "file.png")
end tell
答案 1 :(得分:0)
尝试将其组合成字符串
reveal POSIX file (("/Users/Torben/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/" & "file.png") as text)
答案 2 :(得分:0)
系统事件处理POSIX路径要好得多,但这只是这些AppleScript怪癖中的另一个。 POSIX file
将在 Finder tell
语句的外部中起作用:
set x to POSIX file (pathVariable & otherPathVariable)
tell application "Finder"
activate
reveal x
end tell
但内部是 Finder tell
语句,您需要将其用作强制:
tell application "Finder"
activate
reveal (pathVariable & otherPathVariable) as POSIX file
end tell