我正在尝试创建一个AppleScript代码段,用于查找当前的随机壁纸并在Finder中显示它。我有以下代码片段,它将当前壁纸的POSIX路径作为字符串找到:
set plistFolderPath to path to preferences folder from user domain as string
set plistPath to plistFolderPath & "com.apple.desktop.plist"
tell application "System Events"
tell property list file plistPath
tell contents
set thePath to value of property list item "NewChangePath" of property list item "default" of property list item "Background" & "/" & value of property list item "LastName" of property list item "default" of property list item "Background"
end tell
end tell
end tell
thePath
现在是一个形式的字符串:
/ Volumes / Archive / Widescreen wallpaper / 12345_Name_2560x1440.jpg
(注意空格)
我尝试在FInder中显示此路径,但我尝试过的所有内容都会导致错误:
tell application "Finder"
reveal POSIX file of quoted form of thePath (* Error: "Can't get POSIX file of (blah)" *)
end tell
当我拥有的是POSIX路径时,如何在AppleScript中显示Finder中的路径名?
reveal POSIX file thePath
它,则返回“无法获取POSIX文件<路径>”错误。