Setting a Photoshop Script running from Bridge

General Discussion of Scripting for Adobe Bridge

Moderators: Tom, Kukurykus

Mike Hale

Setting a Photoshop Script running from Bridge

Post by Mike Hale »

I think what is happening is that that when you normally run a script Photoshop knows the folder the script is in. When there is an include that doesn't have the full path, Photoshop looks in that folder for the file. Because the script here is being run by eval, Photoshop doesn't know where to look and can't find the included file

It never hurts to use the full path. The include directive will need to be edited in any case. Doing an eval will run the file you wanted included. However, you will still get the error when you eval the original script because Photoshop still can't find the file. So if you want to go that way you will need to remove the include statement.

I would think that any scoping issues would be the same either way.

Mike
v.bampton

Setting a Photoshop Script running from Bridge

Post by v.bampton »

Ok, having tried a million and one different solutions today, I came to the following conclusions:

* It works perfectly as long as it has the full path
* It doesn't like the external file to have any includes whether they have a full path or not
* //@includepath didn't help unless it had a fixed full path either

I can't use a full path as this script is to run on numerous different machines, both Mac and PC and the path will therefore vary. In the end I've given up and tacked the external file contents on to the end of the main script instead of including it as external, and it's working great - and I've learned loads in the process! Thanks for your help in narrowing it down!
Mike Hale

Setting a Photoshop Script running from Bridge

Post by Mike Hale »

OK, so it can hurt to use full paths. You're right I should have considered that.

I found that you can use a relative path if it's relative to Photoshops app.path. So in your case you would use...

Code: Select all#include "../Photoshop CS/Presets/Scripts/ShoppingCartHTML 460b.jsx"

Assuming the script is in the scripts folder.

Hope that helps and sorry for the bad advice.

Mike
Andrew

Setting a Photoshop Script running from Bridge

Post by Andrew »

Bear in mind that app.path is for photoshop but Folder.commonFiles is for Bridge - and of course there are other startpoints that can be used for setting up relative paths as well.

Andrew
v.bampton

Setting a Photoshop Script running from Bridge

Post by v.bampton »

Mike Hale wrote:OK, so it can hurt to use full paths. You're right I should have considered that.

I found that you can use a relative path if it's relative to Photoshops app.path. So in your case you would use...

Code: Select all#include "../Photoshop CS/Presets/Scripts/ShoppingCartHTML 460b.jsx"

Assuming the script is in the scripts folder.

Hope that helps and sorry for the bad advice.

Mike

Mike, that's great! I'll give that a shot!

That's basically what I'd been trying to end up with, but I'd been trying things like
Code: Select all#include app.path + "/Presets/Scripts/ShoppingCartHTML 460b.jsx" which didn't work.

Thanks, that's an ideal case scenario for this script!

Andrew - thanks for the warning. This particular script is basically a PS script which I just want to be able to launch from Bridge, but I'll remember that for the next one. You guys are great!!!!!
Mike Hale

Setting a Photoshop Script running from Bridge

Post by Mike Hale »

v.bampton wrote:That's basically what I'd been trying to end up with, but I'd been trying things like
Code: Select all#include app.path + "/Presets/Scripts/ShoppingCartHTML 460b.jsx" which didn't work.

As I understand it, include is a preprocessor statement so you can't build the include path using expressions. You also can't do something like set the path base with Folder.current = '/c/temp' for the same reason. The include statement is processed before the Folder.current statement. So the path base for an include statement needs to be a folder Photoshop already knows and will search.

There may be other folders that you can base an include - I didn't test to find them.

For normal relative paths in a script, Andrew is right, There are a lot of ways to set the relative path base. But I couldn't find a way to set the base to say '/c/temp' for the include.

Mike