Sub topic 14
Troubleshooting failed or stalled batches
This chapter assumes you can record an action, run the Batch command, and set a batch's source, destination and file naming. It covers what to do when a batch stops, skips files, or produces the wrong output. It also covers how to build actions so they fail less often.
How batches fail
Almost every batch problem falls into one of three types:
- Stalls. A dialog box appears and nothing continues until someone clicks it.
- Errors. A step in the action cannot run on a particular file, so Photoshop stops or skips that file.
- Silent wrong output. The batch finishes, but files are overwritten, misnamed, in the wrong format, or processed incorrectly.
Diagnose these in that order. Stalls are the easiest to spot and silent wrong output is the hardest.
Set up error reporting before you run
In the Batch dialog, the Errors menu decides what happens when a file fails.
- Stop For Errors halts the whole batch at the first problem. Use it while you test an action on a small folder.
- Log Errors To File keeps going and writes each failure to a text file you choose. Use it for large runs that you leave unattended.
When you use the log option, Photoshop asks you to name the log file. Each entry shows the file and the reason it failed, such as a command that is not currently available. If the log is empty and files are still missing, the cause is not an error. Look at the source settings and the destination settings instead.
Always test on a copy of five to ten representative files. Include the largest file, the smallest file, a portrait image and a landscape image, and any file in an unusual mode or format.
Dialogs that block the run
A batch that hangs with no activity usually has a dialog waiting on screen. Photoshop may be behind another window, so check the taskbar or Dock.
| Dialog | Cause | Fix |
|---|---|---|
| Open options (such as camera raw or PDF import) | The file type needs choices on open | Select **Suppress File Open Options Dialogs** in the Batch dialog |
| Embedded profile mismatch or missing profile | The file's color profile differs from your working space | Select **Suppress Color Profile Warnings** |
| JPEG Options or PNG Options | The action's Save As step shows its own options | Turn off the dialog toggle for that step, or let the Batch destination handle saving |
| Missing fonts | A text layer uses a font that is not installed | Install the font, or replace it before the batch |
| Flatten or layers prompt | Saving to a format that needs a flat image | Add a Flatten Image step, or save to a format that keeps layers |
| A modal dialog from a recorded step | The action has a dialog toggle turned on | Turn it off in the Actions panel |
The second and third rows are the ones people hit most often. Modal controls were useful when you ran the action by hand, but they stop an unattended batch. In the Actions panel, the box to the left of a step turns the step on or off, and the box to its right turns the dialog on or off. A dialog icon beside a step means the batch will pause there.
Save As and Open: the override settings
Two checkboxes in the Batch dialog control where files are opened and saved. Getting them wrong causes the most confusing output problems.
- Override Action "Open" Commands makes the batch open its own files and ignore any Open step recorded in the action. If your action contains an Open step and you leave this off, the action opens the file it recorded, not the file the batch chose. Each pass then works on the same image.
- Override Action "Save As" Commands makes the batch save using your destination folder and file naming. If you leave it off, the action's own Save As step writes the file to the folder where you recorded the action. That is why files appear in an unexpected place, or why the destination folder stays empty.
A good rule: if the destination is set to Folder and the action also contains a Save As, turn the override on. Delete the Open step from the action unless you need it.
The Save and Close destination overwrites the original files. Never run it on your only copy.
Errors from the action itself
When an action works on one image and fails on another, the action assumes something about the image that is not always true. Typical assumptions:
- A layer or channel name. A step that selects "Background" fails on a file whose layer has a different name or no such layer. This produces the "missing layer" error in the log.
- A fixed size or position. A recorded selection or crop in pixel coordinates lands in the wrong place on a different-sized file. Use percentages or a command such as Fit Image where possible.
- A color mode or bit depth. Many filters and adjustments are unavailable in Indexed Color, Bitmap, or some 16-bit and 32-bit situations. The step reports "not currently available".
- A selection that does not exist. A step that needs an active selection fails when the earlier step that creates it produced nothing.
- A single layer. A step that acts on the active layer fails on a flattened image with no extra layers, or does something different.
To find out which one you have, open the failing file named in the log and play the action on it, one step at a time. In the Actions panel, hold Ctrl (Windows) or Cmd (Mac) and double-click a step to play only that step. The step that stops with an error is the one to fix.
Fixes, in order of preference:
- Add a step at the start that puts every file into a known state, such as Convert to RGB 8-bit, then Flatten Image.
- Use Insert Menu Item or relative commands instead of recorded coordinates.
- If the problem only affects a few files, move them out of the source folder and process them separately.
Format mismatches
If files are missing from the output, check what the batch actually opened. The Batch dialog processes only the file types Photoshop can open. Hidden or unsupported files in the source folder are skipped without an error.
- Subfolders. Files in subfolders are ignored unless Include All Subfolders is selected.
- Unsupported types. Raw files from a new camera model, for example, may need an updated Camera Raw plug-in before they open at all.
- Wrong extension. A Save As step that writes a JPEG to a file name ending in
.pngleads to confusing results. Let the batch's file naming section pick the extension. - Name collisions. Two source files with the same name in different subfolders write to the same output name, and the later one replaces the earlier one. Add a serial number or a folder name in File Naming to avoid this.
- Transparency. Saving to JPEG flattens transparent areas against the matte color, so a transparent PNG may come out with a white background.
Compare the count of files in the source folder against the count in the destination. A difference points to skipped or overwritten files.
Resource problems
A very long batch can slow to a crawl or crash.
- The scratch disk may be full. Check free space on the scratch drive before you start.
- Large files processed one after another can fill memory. Close other applications, and use Edit > Purge > All at the start of a run.
- Network drives and cloud-synced folders can drop connections or lock files mid-batch. Copy the files to a local folder first, run the batch there, and copy the results back.
- Files that are read-only, or in a folder you lack permission to write to, fail at the save step.
Taking control with a script
When you need per-file error handling that the Batch dialog does not offer, a short ExtendScript can run the action and record each failure. This script turns dialogs off, runs an action on every image in a chosen folder, and writes failed file names and messages to a log on your desktop.
#target photoshop
var previousDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
var inputFolder = Folder.selectDialog("Choose the folder of images to process");
if (inputFolder) {
var logFile = new File(Folder.desktop + "/batch-errors.txt");
logFile.open("w");
var files = inputFolder.getFiles(function (f) {
return f instanceof File && /\.(jpe?g|png|tiff?)$/i.test(f.name);
});
for (var i = 0; i < files.length; i++) {
var doc = null;
try {
doc = app.open(files[i]);
app.doAction("Resize for Web", "My Actions");
} catch (e) {
logFile.writeln(files[i].name + ": " + e.message);
}
if (doc) {
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
logFile.close();
}
app.displayDialogs = previousDialogs;The action name and set name must match the Actions panel exactly. A wrong name is itself a common cause of an error. The script closes each document without saving, so the action must include its own save step.
A checklist for a batch that misbehaves
- Test on a copy of ten files, including the extremes.
- Set Errors to Log Errors To File.
- Select both suppress options for dialogs and color profiles.
- Turn off dialog toggles inside the action.
- Check both override boxes against what your action contains.
- Open the first failing file and step through the action by hand.
- Compare file counts and spot-check a few outputs.
Exercise
A batch runs without errors and the log is empty, but the destination folder you chose is empty. The action ends with a recorded Save As step. What is the most likely cause, and how do you fix it?
Show answer
"Override Action 'Save As' Commands" was left off, so the action's own Save As step wrote the files to the folder where the action was recorded instead of the destination folder. Select Override Action "Save As" Commands in the Batch dialog (or remove the Save As step and let the destination do the saving), then rerun on a small test set.
Exercise
A batch on 400 images stops at image 37 and Photoshop shows no error, only an unresponsive window that is waiting. Name two likely causes and the setting that addresses each.
Show answer
One cause is a file open or color profile dialog, fixed by selecting Suppress File Open Options Dialogs and Suppress Color Profile Warnings. Another is a dialog toggle left on for a step in the action (such as a Save As options dialog), fixed by turning off the dialog box beside that step in the Actions panel.