# Path trouble

Working on an Automator action. I’m having some trouble getting paths in the right format.

I’ve got this:

``````        tell current application to set prefs_file to (the prefs_folder & "com.Automator.chit.plist") as unicode text
tell application "System Events"
set fileStatus to false
set fileStatus to exists disk item prefs_file
end tell
if fileStatus is false then
display dialog "You must have an Open command before you can Render."
return input
end if

``````

Which is throwing this error:

``````Can't get «class posx» of "Macintosh HD:Users:wanderer:Library:Preferences:com.Automator.chit.plist". (error -1728)
``````

prefs-file is a legit HFS path, I just can’t seem to get it coerced into something that works with the System Events exists call.

Are you sure about that? How do you define prefs_folder? If I define prefs_folder as “path to desktop”, which I think returns an hfs path, your code works fine.

Ric

I’m defining prefs_folder this way:

``````        set the prefs_folder to (path to preferences folder from user domain) as Unicode text

``````

Problem here?

Hmm… I ran the following, and it worked fine:

``````on applicationWillFinishLaunching_(aNotification)
set the prefs_folder to (path to preferences folder from user domain) as Unicode text
tell current application to set prefs_file to (the prefs_folder & "com.apple.Safari.plist") as unicode text
tell application "System Events"
set fileStatus to false
set fileStatus to exists disk item prefs_file
end tell
log fileStatus
log prefs_file
if fileStatus is false then
display dialog "You must have an Open command before you can Render."
return input
end if
end applicationWillFinishLaunching_
``````

I do get an error about “input” not being defined when my file is not found, but that’s another problem. If I substitute a file name that is in my preferences folder, then it works

Ric

No problem, but too complicated

``````        set the prefs_folder to (path to preferences folder as text)

``````

user domain is the default behavior and unlike most other cases as text is a parameter, not a coercion

Okay, I cleaned the project and rebooted, and now it’s fine. Sorry I didn’t do that before posting!

Another problem:

How can I get this:

``````(
"<NSAppleEventDescriptor: 'furl'("Macintosh%20HD:Users:wanderer:Desktop:photo-8.psd")>"
)
``````