• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Use Relative Path for Photoshop Action?

New Here ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

I have a Photoshop Action that is programmed to open an existing file located in a specific directory.  The path to this directory is an absolute path, i.e.:

C:\Program Files\Photoshop Actions\filename.jpg
As long as the Action can find the file in the specified absolute path, everything works fine.
My problem is that if someone tries to run this Action on a different computer (like a Mac), the path specified in the action does not exist and the Action will not work.
The simple solution to this would be to make the action open the file located at a relative path.  This way no matter what computer the action is run on, it will always be able to find the file.
Unfortunately, I don't think Photoshop Actions allow relative paths.  Does anyone know if using a relative path in an action is possible?
Failing this, how would I use a Photoshop Script to somehow direct the Action to find the correct location of the file?  Or is there a better solution?

TOPICS
Actions and scripting

Views

10.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

One way would be to have the script open the picture from a known folder (home) and then call the action to run on the selected picture IE:

#target photoshop
var myFile = File("~/myPic.jpg");
open (myFile);
doAction(actionName, actionSet);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

Thanks for the quick response.  So does this mean if I'm distributing this Action and Script to other users that I would have to make sure that the file "myPic.jpg" is copied into a folder relative to the user's home folder?  Would this work for both PCs and Macs? 

Would it be possible to use a relative path instead of the home folder?  Like:

var myFile = File("images/myPic.jpg");

Would this work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

No that would not work!

#target photoshop
var myFile = File("~/myPic.jpg");
open (myFile);
doAction(actionName, actionSet);

This would work on all systems. So long as the picture was put in the home folder.

You could have a folder off Home if you wanted

var myFile = File("~/images/myPic.jpg");
You would of course have the user copy the files into the correct places, or write an install script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

You should have a look at Xbytor's xtools http://ps-scripts.com/bb/viewtopic.php?t=2333

It has a javascript that you could adapt that would allow any actions that have file paths changed when distributing actions. The end user would only have to run the install script once to update the action to the new path.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

Thanks Michael.  I will take a look at this.  At first glance, there's not a lot of documentation.  Is it difficult to use?  Anything you can suggest to point me in the right direction?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

LATEST

The idea that I use in the xtools installer and else where is this:

1) Convert the action file to XML.

2) Package the XML file and the apps/ActionFileFromXML script with your stuff.

3) An installer script will do a 'replace' (or whatever) on the XML file so that the paths are converted to whatever is needed.

4) The new XML is saved and then converted to a .atn file which is then loaded.

There is an xtools forum at ps-scripts.com that may have some info in addition to the PDF file that comes with the package.

-X

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines