Skip to main content
keid
Participant
May 12, 2013
Question

Run script with action.

  • May 12, 2013
  • 1 reply
  • 634 views

Hello,

Please imagine that I have to combine 2 files. On first file I have to add some adjustments, etc +  secon file (multiply them (ambient occlusion)).

What am I doing? I'm creating action which will do that, one thing I can't do is to open specific file.

I have thousands of files like that:


file0001
file0001_ambientOcclusion

file0002

file0002_ambientOcclusion

file0003

file0003_ambientOcclusion
...


I've never used script before, but I think that would be solution for me.

Question is: How to create script to open filename+sufix in the same folder. What's more is fact I have to run this scrip in single action (alt+F9)

This topic has been closed for replies.

1 reply

Participating Frequently
May 23, 2013

var pathToOpenFile = activeDocument.path;

var nameOfOpenFile = activeDocument.name.replace('.psd','');  // that removes a psd file extension if it has one

var secondFile = new File(pathToOpenFile + '/' + nameOfOpenFile + '_ambientOcclusion.psd');

photoshop.open(secondFile);

this is written for psd files, but can be adjusted easily for other filetypes.Save that as a .jsx file in your scripts folder and restart photoshop if its open.  In your action, where you need to open the '_ambientOcclusion' file, insert this script. This page has info on where to put the script, and how to insert a script into an action.  Hope this helps with your goal.

keid
keidAuthor
Participant
May 23, 2013

Ouh,
I've written something like that already, but anyway: Thanks for help : ).

Participating Frequently
May 23, 2013

Maybe it will help someone else in the future.  Next time you ask a question and figure it out yourself,consider updatig your post so others in the same boat can find it here.