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

Automate - Batch - Action Question

New Here ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied

Would it be possible to run an action on selected open images not just all of the open images at the time ?

 

Ideally I would like to batch run this saved action on my open 'Untitled' images and not apply the action to the other original images that are open at the time.

 

Could you please let me know if this would be achievable ? And how best to do this.

 

Thanks for taking the time to read my post, I welcome your thoughts.

TOPICS
Actions and scripting , macOS

Views

152

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

correct answers 1 Correct answer

Community Expert , Jul 08, 2022 Jul 08, 2022

The following script will only run the Default Action set and Molten Lead action on files that have never been saved.

 

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/automate-batch-action-question/td-p/13056955
*/

#target photoshop

for (var i = 0; i < app.documents.length; i++) {
    activeDocument = app.documents[i];
    try {
        app.activeDocument.path;
        // Do nothing for previously saved files
    } catch (e) {
        // Run action on unsaved files
        a
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied

I expect this would take a Script, so a plain Batch would not suffice. 

Depending on the situation an Action with a Conditional in a Batch might suffice, though. 

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 ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied


@c.pfaffenbichler wrote:

I expect this would take a Script, so a plain Batch would not suffice. 

 

That was my first thought, then I got stuck in infinite loops!

 


Depending on the situation an Action with a Conditional in a Batch might suffice, though. 


 

Good suggestion! The invert action in this example is only applied to unsaved files, so make sure that all open files have been saved, except for the Untitled-# ones!

 

batch-conditional.png

 

I'd still be interested in seeing the scripted version!

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 ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied

The following script will only run the Default Action set and Molten Lead action on files that have never been saved.

 

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/automate-batch-action-question/td-p/13056955
*/

#target photoshop

for (var i = 0; i < app.documents.length; i++) {
    activeDocument = app.documents[i];
    try {
        app.activeDocument.path;
        // Do nothing for previously saved files
    } catch (e) {
        // Run action on unsaved files
        app.doAction("Molten Lead", "Default Actions");
    }
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

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 ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied


Good suggestion! The invert action in this example is only applied to unsaved files, so make sure that all open files have been saved, except for the Untitled-# ones!


That’s exactly the »situation«, but any unsaved changes (and that might include inocuous stuff like Layer visibility changes) could cause unintended results. 

 

A Scripting-approach could be something along these lines: 

 

var theDocs = app.documents;
var theUnsaved = [];
for (var m = 0; m < theDocs.length; m++) {
    var thisDoc = theDocs[m];
    try {thisDoc.path}
    catch (e) {
        app.activeDocument = thisDoc;
        alert (thisDoc.name+" is unsaved");
        theUnsaved.push(thisDoc)
    }
};
alert ("the unsaved files are \n"+theUnsaved.join("\n"));

 

 

Edit: I see you already got a Script running. 

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 ,
Jul 08, 2022 Jul 08, 2022

Copy link to clipboard

Copied

LATEST

@c.pfaffenbichler – Thank you for sharing some code and thoughts.

 


Edit: I see you already got a Script running. 


 

I forgot that a while loop should only be used when closing down documents, so I had to swap it for a for loop, but then I was spinning my wheels a bit before I got it working.

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