13 Replies Latest reply on Oct 5, 2017 5:40 PM by thejoed1

    Help with opening a Photoshop file using Javascript

    thejoed1

      Hello and thanks for your time beforehand,

       

      I'm new to Javascript and scripting for Photoshop. I'm trying to understand how to open a psd file using Javascript and cannot figure it out.

       

      The code I'm working with is below:

      =============================

      //OPEN A FILE ON A MAC

      //Not clear on the correct syntax structure to target a file

      var fileRef = File(app.path + "/file.psd")

       

      //Open the file at the path specified above

      if (fileRef.exists){

          var docRef = app.open(fileRef);

      }

       

      //If the file above does not exsist show this

      else{alert("File does not exsist.");}

      =============================

       

      The "/file.psd" part is my snag, I think.

       

      What is the correct way to target the file?

      Is it best to use a relative or absolute path?

      Is a relative path based on the location of the script?

       

      I know that with html one can target using"../../directory/file.jpg" and is that how Javascript works? I can't find any documentation that addresses this.

       

      Any help is appreciated,

       

      ~ Joe D