Path to XML file

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Gonzaga

Path to XML file

Post by Gonzaga »

Hello,

I'm working on a script that loads and saves its setting from and to an XML file. This file is supposed to be located in the same folder as the script. In my case this is the Scripts-Folder in Photoshop.
Sometimes I had issues with the script not finding the XML file although the source code was the same as always. My question is, how I'm supposed to formulate the path of the File command so that the script will always find the XML file in the same folder.

So far my path was used like this ... (although this caused the problems then and now).
var f = new File("./Presets/Scripts/Settings.xml");

Thanks for all the help,
Andreas

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Path to XML file

Post by Mike Hale »

If I understand what you are asking, use the full path when creating the file object.
Code: Select allvar scriptsPath = app.path + "/" + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
var f = new File(scriptsPath+"/Settings.xml");
Gonzaga

Path to XML file

Post by Gonzaga »

Thanks Mike,

that did the trick. I hope this is platform compatible so it will work on Mac and PC.

Cheers,
Andreas