Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

How to open an image in the same folder as a script (relative path)

$
0
0

Using Javascript with Photoshop CC (on Windows), I'm trying to create a script that will create a new document of certain dimension size, open an existing image alongside it, and paste it in as a new layer.

 

My problem is, I can only open the existing image when I supply the absolute path as follows:

 

var fileRef = new File("C://Users//James//Desktop//images//image01.jpg");

 

I had thought (obviously incorrectly since it won't work) that I could just specify the name of the file in the call to the new File object, e.g.:

 

var fileRef = new File("image01.jpg");

 

but this returns an 1233 error, i.e. "Expected a reference to an existing file or folder" so obviously the script can't see the file.

 

Is there a way to provide a relative address? This is for an assignment which will be viewed on a Mac so providing an absolute address which works on my PC isn't much good.

 

Thanks.


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>