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

Scripting: can I throw an error in the standard batch from script?

Guide ,
Nov 17, 2019 Nov 17, 2019

I have a script that is often used in conjunction with standard batch processing. The behavior of the script depends on the user's settings and there are situations when it ends with an error. However, batch processing does not end at the same time - it opens the next file and the script terminates again and again with an error and so on until the files run out.

 

Is there a way to tell the standard batch processor that the script completed with an error so that it stops processing (i.e., something like when batch processing cannot complete the operation and suggests stopping)?

TOPICS
Actions and scripting
2.6K
Translate
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

People's Champ , Nov 17, 2019 Nov 17, 2019
Radical way )
 
If an error occurs, if there are no unsaved open documents, the script will create an empty new doc and make any step in the history.

Next, run the command.

 

executeAction(stringIDToTypeID("quit"), undefined, DialogModes.NO);

 

P.S. The "stop" command fails as well as an error throw. Probably a bug in all versions of Photoshop ))

 

 
Translate
Adobe
Community Expert ,
Nov 17, 2019 Nov 17, 2019

If you use an script in an action and the script has dependencies on settings or document content  make the settings  or document content before the actions script step. The script will fails if a dependency is missing. If you get an error messages you need to cancel the processing there has been an error. If the Batch stop on error] does not stop  batch process.

image.pngexpand image

JJMack
Translate
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
Guide ,
Nov 17, 2019 Nov 17, 2019

That’s the problem: if the script is written by user as a command in the actions panel, batch cannot understand whether there was an error while executing the command or not (even if I took into account and processed this error inside the script)
As an example, in video i call to the "example" command in the operation panel contains a call to the script "Source1.jsx", which contains obviously inoperative code that causes an error. Batch does not notice that the script was executed with an error and continues execution for each file ( stop for errors is enabled). Of course, I can handle this error inside the script, but this will not change the situation - the script will not be able to stop the batch until all files are opened.

 

 

Is there any way to stop the batch in such a situation? (i.e. shut down the script so that the batch understands that an error has occurred)

Translate
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
People's Champ ,
Nov 17, 2019 Nov 17, 2019
Radical way )
 
If an error occurs, if there are no unsaved open documents, the script will create an empty new doc and make any step in the history.

Next, run the command.

 

executeAction(stringIDToTypeID("quit"), undefined, DialogModes.NO);

 

P.S. The "stop" command fails as well as an error throw. Probably a bug in all versions of Photoshop ))

 

 
Translate
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
LEGEND ,
Nov 19, 2019 Nov 19, 2019

First of all, you don't need to use Batch. Just do a loop in your script.

You could also set a variable (flag) when you trap the error and then test for that flag for each file, and just close the files instead of continuing to process.

Translate
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
Guide ,
Nov 19, 2019 Nov 19, 2019

This is obvious, but it does not correspond to the tasks that I solved when writing a script 🙂

Translate
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 Beginner ,
Oct 25, 2020 Oct 25, 2020

Hey, this is a old one but this one help me top stop batch processing.

This script avoid the error message and doesn't quit photoshop. But it can be better i just don't know how to do it yet.

You just have to create a new document and make a random modification so it will ask you if you want to save it, then you can stop the batch processing without quitting photoshop. not very academic but it works.

 

//avoid the error message if no document is open

if (documents.length == 0){

if (confirm("is a batch processing running ?") == true){
alert("The batch processing will crash ")
app.documents.add(800 ,400 ,72 , "new document", NewDocumentMode.RGB)
var textlayer = app.activeDocument.artLayers.add()
textlayer.name = "my texte"
textlayer.kind = LayerKind.TEXT
var contenutext = app.activeDocument.artLayers["mon texte"].textItem
contenutext.contents = "you can close this document without saving it"
alert("Click on "stop" the processing and then on "cancel" if you don't want to quit photoshop ")

executeAction(stringIDToTypeID("quit"), undefined, DialogModes.NO)

}
}

else{

//you're script here

}

 

 

note that the text layer is only here to guide the user, you can just create an empty layer it will work just fine.

i bet there is another "executeAction>quit" that can break the loop of the batch processing, but i don't know wich one.

 

Hope the will help.

Translate
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 Beginner ,
Oct 25, 2020 Oct 25, 2020

your* sorry for the bad english oupsii

Translate
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
Guide ,
Oct 26, 2020 Oct 26, 2020

Thanks. However, the problem is that the script does not always work in conjunction with batch and generating a new document window on every error is not the best solution, since it will interfere with work.
I did it differently - I just wrote my batch processor 🙂

Translate
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 Beginner ,
Oct 27, 2020 Oct 27, 2020

indeed that is a solution. probalby the best.

 

i have to keep it simple and transparent in order to my team to handle bugs and problems without opening and understanding the scripts. That is why i try to keep it as much in the photoshop window as possible 🙂

Translate
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
Guide ,
Oct 27, 2020 Oct 27, 2020

Likewise. However, the task of scripts is precisely that - not just duplicate, but expand the existing functionality of Photoshop.2020-10-27_23-24-07.pngexpand image

Translate
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 Beginner ,
Oct 28, 2020 Oct 28, 2020
LATEST

that looks awesome but i clearly cannot script a thing like yet, haha !

Translate
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