Skip to main content
Inspiring
October 3, 2023
Answered

Unable to open a file with scripting in Photoshop

  • October 3, 2023
  • 1 reply
  • 179 views

I'm attempting to open a file programmatically with scripting in photoshop my code is:

 

#target photoshop
    app.preferences.rulerUnits = Units.PIXELS;
    var doc_a = app.open( new File("/Users/ohms/Desktop/myfile.psd") );

 

 

I don't get an error it just doesn't do anything.  I also added and try / catch block but the same no results.

This topic has been closed for replies.
Correct answer Stephen Marsh

Untested, but I'd suggest either using a full absolute path or a relative path:

 

 

"~/Desktop/myfile.psd"

 

 

It may or may not matter, but why new File and not File ?

 

var theFilePath = "~/Desktop/myfile.psd";
app.open(File(theFilePath));

 

app.open(File("~/Desktop/myfile.psd"));

 

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
October 3, 2023

Untested, but I'd suggest either using a full absolute path or a relative path:

 

 

"~/Desktop/myfile.psd"

 

 

It may or may not matter, but why new File and not File ?

 

var theFilePath = "~/Desktop/myfile.psd";
app.open(File(theFilePath));

 

app.open(File("~/Desktop/myfile.psd"));