Sub topic 13
Branching with Conditional Actions
Prerequisites and working model
Assume you can create and play actions, organize them in action sets, and recognize common document properties such as color mode, layers, and embedded profiles. You should also know how to open the Actions panel and save an action set.
A conditional action chooses between two existing actions. Photoshop checks a document property, then plays one action when the condition is true and another when it is false. This is useful when one batch contains files that need slightly different treatment.
For example, RGB images might use an RGB sharpening action, while CMYK images use a CMYK sharpening action. The batch still starts one main action, but the conditional step sends each document to the correct branch.
Create the two branch actions
Create and test each branch before adding the condition. For an RGB and CMYK example:
- Record an action named
Prepare RGB. - Add the RGB-specific steps, such as converting or sharpening with settings chosen for RGB work.
- Stop recording and test the action on a copy.
- Record a separate action named
Prepare CMYK. - Add the steps appropriate for CMYK files.
- Test it on a CMYK document.
Keep each branch focused. If both branches contain common steps, place those steps before or after the conditional action in the main action. Duplicating common steps makes later edits harder.
Insert the conditional step
Open the Actions panel menu and choose the command for inserting a conditional action. In the dialog, choose:
- The document property to test.
- The action to play when the condition is true.
- The action to play when the condition is false.
The available conditions depend on the Photoshop version. Common examples test whether a document uses a particular color mode, has layers, or has an embedded profile. Choose actions from the correct action set, then confirm the insertion.
You can also use Photoshop's conditional mode-change command when the goal is specifically to change a document's color mode based on its current mode. That command is narrower than a conditional action because it does not let you build two general-purpose processing branches.
Avoid common failures
A branch can fail even when the condition works correctly.
- The selected action was renamed or moved. Keep the branch actions in the same saved action set.
- A branch expects a layer that does not exist. Add a layer check, create the required layer in both branches, or make the action tolerant of different layer structures.
- The condition checks the wrong property. Test it on a document that clearly meets the condition and another that clearly does not.
- A modal dialog interrupts the batch. Disable unnecessary dialogs in the action and test unattended playback.
- The false branch is empty or inappropriate. Use an action that safely prepares the file, or make the main action stop for review when neither branch is safe.
Test the complete parent action on representative files. Include at least one file for each branch and one file with unusual properties, such as no layers or no color profile.
Exercise
You need one batch action for RGB and CMYK files. Which design is safer: put RGB steps in the main action and add a CMYK branch, or create two complete branch actions and use a condition to select between them?
Show answer
Create two focused branch actions and use a condition to select between them. Keep shared steps outside the branches so both paths receive the same preparation and cleanup.