I want to write a script that gets the path of the frontmost document in the app “pages”. Then display the path in a dialog and ask me what a want to do with the path. Or it has to open the parent directory or just nothing.
It all goes well until the opening of the folder in a new finder window. Pages returns a POSIX path and I don’t know how to change a POSIX path into an alias. When I try to set the target of the frontmost finder window to the container of the POSIX Path of the path to the document, it says that the folder does not exists.
My script:
tell application "Pages"
set myPath to path of document 1
set myString to myPath & return & return & "What do you wanna do?"
display dialog myString buttons {"Nothing", "Open Container"} default button 2
if button returned of result is "Open Container" then
tell application "Finder"
make new Finder window
set target of Finder window 1 to container of (POSIX path of myPath)
tell result to activate
end tell
end if
end tell
Thanks in advance,
ief2
PS.: I’m sorry for my English. I know I sometimes make some rubbish sentences, but I ask you to forgive me. I’m only 14 years old and I come from Belgium, so I speak dutch. If you don’t understand me, don’t hesitate to give a reply on that.
Model: iMac G5
Browser: Safari 531.9
Operating System: Mac OS X (10.5)