I'm trying to create an AppleScript snippet that locates the current random wallpaper and reveals it in Finder. I have the following snippet which finds the current wallpaper's POSIX path as a string:
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
is now a string in the form:
/Volumes/Archive/Widescreen wallpaper/12345_Name_2560x1440.jpg
(Note spaces)
I try to reveal this path in FInder, but everything I've tried results in an error:
tell application "Finder"
reveal POSIX file of quoted form of thePath (* Error: "Can't get POSIX file of (blah)" *)
end tell
How do I reveal a pathname in Finder in AppleScript when all I have is its POSIX path?