Sub topic 9
Running an Action on a Folder with Batch
This chapter assumes you can record and play an action from the Actions panel, and that you know the basic file formats (JPEG, PNG, TIFF, PSD). Here you will use the Batch command to play one action on many files at once. Source, destination and naming options get a deeper treatment in the next chapter. This one covers the working model, a first run, and the errors that show up most often.
What Batch does
Batch is a Photoshop command that repeats one action over a group of files. For each file it does the same four things:
- Opens the file.
- Plays the chosen action on it.
- Saves or closes the result, depending on your destination setting.
- Moves on to the next file.
You find it under File > Automate > Batch. The dialog has four areas: Play (which set and action), Source (where files come from), Destination (what happens to the result) and Errors (what to do when something fails).
Prepare before you batch
Most failed batches come from skipped preparation. Work through this checklist first.
- Test the action on one file. If it fails on a single image, it will fail on all of them.
- Copy your originals. The Save and Close destination overwrites files. Work on a duplicate folder until you trust the action.
- Put the files in one folder. Remove files the action cannot handle, such as a PDF in a folder of photos.
- Check that the action does not depend on a specific layer or selection. Chapters on portable actions cover this in detail.
- Decide how the action saves. If it already contains a Save As step, you need to understand how that interacts with the Batch destination (see below).
A first batch, step by step
Suppose you have an action named Resize for Web in a set called My Actions. It resizes an image and applies a sharpening filter. You want to run it on every file in a folder of photos and write the results to a different folder.
- Create two folders, for example
photos-inandphotos-out. Put copies of your images inphotos-in. - Choose File > Automate > Batch.
- Under Play, choose Set: My Actions and Action: Resize for Web. The Action menu only lists actions in the selected set, so change the set first.
- Under Source, choose Folder, click Choose, and select
photos-in. - Under Destination, choose Folder, click Choose, and select
photos-out. - Leave the file naming options at their defaults for now.
- Under Errors, choose Log Errors to File and name a log file, for example
batch-errors.txt. - Click OK.
Photoshop opens each image, plays the action and saves the result in photos-out. Watch the first few files go through. If something looks wrong, stop the run (press Esc) and fix the action before continuing.
The Source options
The Source menu has four choices.
| Source | What it processes | Typical use |
|---|---|---|
| Folder | Every file in the chosen folder | Most batch jobs |
| Import | Images from a scanner or camera | Scanning a stack of prints |
| Opened Files | Documents already open in Photoshop | A handful of files you are already editing |
| Bridge | Files you selected in Adobe Bridge | Picking a subset by rating or label |
With Folder, two checkboxes matter:
- Include All Subfolders makes Batch descend into every folder inside the source. Without it, only files at the top level are processed.
- Suppress File Open Options Dialogs stops Photoshop from asking questions when a file needs a choice, such as a Camera Raw settings dialog. Turn this on for unattended runs.
- Suppress Color Profile Warnings stops the profile mismatch prompts. Turn this on too if your files have mixed profiles.
A dialog that appears in the middle of a batch pauses the whole run until someone clicks it. The two suppress options exist to prevent that.
The Destination options
Destination controls what happens after the action finishes on each file.
| Destination | Result |
|---|---|
| None | The processed document stays open and is not saved. |
| Save and Close | The original file is overwritten with the processed version, then closed. |
| Folder | A new file is saved in the folder you choose, and the original is left alone. |
Use Folder for any first run. None is useful when the action does its own saving, or when you only want to inspect results. It can fill your screen with open documents, so use it on small batches.
Override Action "Save As" Commands
If your action contains a Save As step, that step has a hard-coded file path from when you recorded it. Without any override, every file would be saved to that same path, and each save would overwrite the last one.
The Override Action "Save As" Commands checkbox fixes this. When it is on, Batch ignores the folder and name stored in the action's Save As step and uses the Destination folder and your file naming settings instead. Photoshop still uses the format and format options from the Save As step, such as JPEG quality.
There is an important catch. This option only works if the action contains a Save As command to override. If the action has no Save As, the checkbox does nothing, and the files are saved in whatever format the originals had. So if you want every result to be a JPEG, the action itself must include File > Save As > JPEG, and Override must be on.
The same applies to Override Action "Open" Commands, which makes Batch ignore any Open step in the action and use the files from the Source instead. Turn this on if you recorded an Open step.
Naming the output files
When Destination is Folder, the File Naming area lets you build a name from parts. Each part is a menu: you can choose a document name in upper or lower case, a serial number, a date, or an extension. A common pattern is Document Name followed by Extension in lower case, which gives you photo1.jpg from photo1.tif. The next chapter covers the naming parts and the Compatibility options in detail.
Handling errors
The Errors menu has two settings.
- Stop For Errors halts the batch at the first problem and shows a message. Good while you are testing.
- Log Errors to File keeps going and writes each failure to a text file. Good for large unattended runs, but you must read the log afterward, because a skipped file does not produce any visible warning.
After a run, compare the number of files in the output folder with the number in the source. A mismatch means some files were skipped, and the log tells you why.
A reliable pattern
For a repeatable result, follow this structure:
- The action starts with the image already open, and does not record an Open step.
- The action ends with a Save As step in the format you want, if you need a specific format.
- Batch uses Override Action "Save As" Commands, a Destination folder, and suppressed dialogs.
- You run the batch on a copy of the files first.
This arrangement separates the work: the action describes what to do to an image, and Batch decides which images and where the results go.
Common errors at a glance
| Symptom | Likely cause | Fix |
|---|---|---|
| Batch pauses and waits | A dialog opened (file options or profile warning) | Turn on both Suppress options; add no stops to the action |
| Every output has the same name and only one file remains | Save As step has a fixed path and Override is off | Turn on Override Action "Save As" Commands |
| Output files are not JPEG | Action contains no Save As step | Record a Save As step in the format you need |
| "The command is not currently available" | The action expects a layer, selection or mode that this file lacks | Make the action check or create what it needs |
| Some files are missing from the output | The files were skipped and logged | Read the error log; check the formats |
| Subfolder images are missing | Include All Subfolders is off | Turn it on |
Exercise
Your action ends with a recorded Save As step that saves a JPEG to your Desktop. You run Batch with Destination set to a folder called out, but Override Action "Save As" Commands is off. What happens, and what do you change?
Show answer
Each file is saved to the Desktop path stored in the action, with the name recorded in the action, so each save overwrites the previous one and only one file survives. A second copy may also be written to out by the Destination step. Turn on Override Action "Save As" Commands so that Batch uses the out folder and your file naming settings. The JPEG format and quality still come from the action's Save As step.
Exercise
You want a batch to resize images and always produce PNG files, but your action only contains the resize step. You choose Destination: Folder and turn on Override. Will the results be PNG files? How do you get PNG output?
Show answer
No. Override has no Save As step to override, so the files are saved in their original format. Add a File > Save As > PNG step at the end of the action, then run Batch again with Override Action "Save As" Commands on.