Copy link to clipboard
Copied
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)?
1 Correct answer
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 ))
Explore related tutorials & articles
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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 ))
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This is obvious, but it does not correspond to the tasks that I solved when writing a script 🙂
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
your* sorry for the bad english oupsii
Copy link to clipboard
Copied
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 🙂
Copy link to clipboard
Copied
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 🙂
Copy link to clipboard
Copied
Likewise. However, the task of scripts is precisely that - not just duplicate, but expand the existing functionality of Photoshop.
Copy link to clipboard
Copied
that looks awesome but i clearly cannot script a thing like yet, haha !

