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

Combining 2 action scripts. when not script 1 then script 2.

Community Beginner ,
Oct 20, 2022 Oct 20, 2022

Copy link to clipboard

Copied

Hi peeps,

 

I'm creating a script for converting 27.000 white background product images with clipping path to transparent .png files. these images have 2 different types. 
- pruduct image with white background and a clipping path around the product
- effect picture of product in use

Right now i created 2 scripts.
1.  deletes the white background with help from clipping path selection.
2.  just exports as png

The problem i'm facing is that when i run the first script, the script skips the images without a path and keeping them open in tabs. at the moment i need to run another batch on the tabs that were not run through the script. this slows the computer down because out of a batch of 1000 pictures around 30% are images that need to run script 2 and. so that means that 300 tabs of pictures will be open in photoshop.

I would like to combine the 2 script so that when action 1 from script 1 cant be done, then run script 2 for that image.

TOPICS
Actions and scripting

Views

136

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
Community Expert ,
Oct 20, 2022 Oct 20, 2022

Copy link to clipboard

Copied

Frankly, I would not have two scripts. I would rewrite them to be in one script and use an if else statement to handle each file then close each file.

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
Community Expert ,
Oct 20, 2022 Oct 20, 2022

Copy link to clipboard

Copied

This will be similar to the following script:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/if-named-channel-exists-run-action-1-...

 

Perhaps something like this:

 

#target photoshop

try {
    activeDocument.pathItems[0].select();
    //alert("A path exists!");
    app.doAction("Action 1", "Action Set 1");

} catch (e) {
    //alert("A path doesn't exist!");
    app.doAction("Action 1", "Action Set 2");
}

 

You will need to change the references to the Actions and Action Sets to match those in your screenshot of the Action panel.

 

P.S. Actions and Scripts are two different things, Photoshop doesn't have "Action Scripts". Your screenshot shows an Action. As there are no conditional path Actions, you'll need a script like the JavaScript above.

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
Community Expert ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

LATEST

@Joeri5E20 - So, how did you go?

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