Skip to main content
Gotta Dance
Inspiring
December 29, 2021
Answered

JSX - Open File in Photoshop

  • December 29, 2021
  • 1 reply
  • 4034 views

Hi everybody,

 

I've been working on this for close to a day. I can't get a file to open in Photoshop no matter what I try to do with something thatI would imagine is relatievly straight-forward.

 

This is the script I'm using in VSCode:

 

// current file path
var filePath = new File($.fileName).parent;
alert(filePath); // works

var fileRef = filePath + "/PSD/test.psd";
alert("file in question: " +fileRef);
// file in question: "~/Documents/adobe_scripts/PSD/test.psd" 

alert(fileRef.exists); //undefined


var docRef = app.open(filePath);
 
// end of script
 
I keep getting 1230 and 1233 argument errors. I've tried to eval, toString, typeOf, trying to figure out why it just won't open...?
 
This is a basic direct reference to a path/file. Is there something right under my nose that I'm missing? If anybody could provide some insight I'd be thrilled.
 
Thanks!
-m
This topic has been closed for replies.
Correct answer Kukurykus

 

open(File(fileRef))

 

1 reply

Kukurykus
KukurykusCorrect answer
Legend
December 29, 2021

 

open(File(fileRef))

 

Gotta Dance
Inspiring
December 29, 2021

Awesome, thank you!

 

(They should have that on Pg. 29 of the manual instead.) 

Kukurykus
Legend
December 29, 2021

I found 2 mistakes in your code:

 

- you tried to open a path (filePath)

- you used not an path object but string

 

btw if it solves the problem mark the solution as correct 😉