Skip navigation
macbeth07
Currently Being Moderated

Relative file path/folder (AppleScript)

Apr 10, 2012 11:40 AM

Tags: #applescript #filepath

How do I set a folder as a realtive path to where the script is running??  

is there any easy way like in unix, starting without / ?

or for example

 

"~/Desktop/"

 

"/users/<login>/desktop/"

 

seems that path to me is the only way...

 

is there an easy way to change posix paths to applescript??

 

I have this code:

 

tell application "Finder" to set templateFile to (container of (path to me) as string) & "Graficas FINAL ADQAT.ai"

 

with this error:

error "No se ha encontrado el archivo Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai." number -43 from "Macintosh HD:Users:Vibra:Desktop:Graficas FINAL ADQAT.ai"

 

the file is there how I change the filepath to be compatible with applescript??

 
Replies
  • Currently Being Moderated
    Apr 10, 2012 1:08 PM   in reply to macbeth07

    Do you just want…

     

    set MyFile to ((path to desktop) as text) & "Test.ai" as alias

     

    tell application "Adobe Illustrator"

      activate

      open MyFile

    end tell

     

    This also works if both files are at the same location…

     

    tell application "Finder" to set templateFile to (container of (path to me) as string) & "Test.ai" as alias

     

    tell application "Adobe Illustrator"

      activate

      open templateFile

    end tell

     

    AppleScript paths are HFS colon separated, most apps like to be passed an AppleScript alias specifier UNIX is POSIX paths a slash separated…


     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 1:50 PM   in reply to macbeth07

    no problem… the coercion to alias confirms the file exists… it should go inside a try and on error if you want to trap/handle errors…

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points