There’s a specific kind of misery that comes from doing the same crop 200 times in a row. I know this because I lived it, about twelve years ago, on a catalog shoot that ran long and left me alone in the studio at 11pm with a folder full of raw files and a deadline that didn’t care about my feelings. Every image needed the same treatment: crop to 2:3, resize to 1200px on the long edge, sharpen at 0.5 radius, export as sRGB JPEG at quality 85. Two hundred times. By hand. That night cost me about six hours of my life I’m never getting back, and it was the last time I ever let it happen.
The next weekend I learned Photoshop scripting. Not because I’m a programmer, but because I was angry enough to figure it out.
What Photoshop Scripts Actually Do That Actions Can’t
Most people use actions and think they’ve hit the ceiling of automation. Actions are powerful, but they’re linear. They execute steps in sequence, with no ability to make decisions. A script, written in JavaScript and run through Photoshop’s ExtendScript engine, can actually think. It can read file metadata, check image dimensions, apply different treatments based on conditions, loop through entire folders, and write output to specific directories, all without you touching the keyboard.
When you run a script, Photoshop exposes its internal object model through a DOM (Document Object Model) that lets you reference and manipulate virtually anything: layers, channels, paths, history states, export settings. The app.activeDocument object is your entry point. From there, you can call methods like resizeImage(), flatten(), or exportDocument() with exact parameters passed as arguments. This is what makes scripting categorically different from recording a macro. You’re not playing back clicks. You’re issuing direct instructions to the application engine.
The Batch Script Structure That Actually Holds Up Under Pressure
Here’s the architecture I use for most product photography pipelines. It’s not exotic, but it’s reliable across different client specs.
The script opens with a folder selection dialog using Folder.selectDialog(), then reads all files in that folder into an array. I filter for .psd and .tif extensions only, because letting a script loose on a folder full of mixed junk is a fast way to have a bad afternoon. Then a for loop opens each file, applies the action set (I still use a pre-built action for the actual image adjustments, called via app.doAction()), runs the resize and export logic, closes the document without saving, and moves to the next file.
The export parameters for JPEG output live in a JPEGSaveOptions object. I set quality to 10 (which maps to approximately quality 85 in the Save for Web dialog), embedColorProfile to true, and formatOptions to JPEGFormatOptions.STANDARDBASELINE. For e-commerce clients who need sRGB delivery, I also convert the color profile before export using doc.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true). That one line has saved me from more client complaints than I can count.
Total script length for a standard product batch: about 80 lines of JavaScript. Not intimidating if you read it in chunks.
Where Scripts Break and How to Build in Failure Tolerance
Scripts fail. Usually because a file is corrupted, a layer name doesn’t match what the script expects, or someone dropped a 400MB panorama into a folder of 20MB product shots and the memory allocation chokes. The fix is error handling, and most tutorials skip this entirely.
Wrap your core loop in a try/catch block. In the catch, write the failed filename and error message to a text log using File object methods. I log to a .txt file in the same output folder, timestamp it, and move on to the next file rather than halting the whole batch. This means a script processing 500 files might fail on 3 of them, log those 3, and finish the rest. You fix the 3 manually. You don’t lose the afternoon.
I also set Photoshop.displayDialogs = DialogModes.NO at the top of every script. If you skip this, Photoshop will pause on any dialog box it encounters during batch processing, and your “automated” workflow becomes a long session of hitting OK every 90 seconds.
The Weekend I Processed 500 Product Shots and Billed for the Strategy, Not the Labor
A client came to me last spring with 500 SKUs that needed white background isolation, shadow addition, and export in three sizes (2000px, 800px, and 400px) for their e-commerce platform migration. The images were already cut out, just inconsistently sized and color-inconsistent across different shooting days.
I spent a Saturday building the script and tuning the action set it called. By Sunday afternoon I ran it end-to-end. Total processing time: 2 hours 47 minutes, unattended. I drank coffee, reviewed the log file for errors (11 files flagged, all fixed in under 30 minutes), and delivered 1,500 export files by 4pm.
The project fee reflected the strategic value of the solution, not the hours of clicking. That’s the actual economic argument for learning this stuff. I track my time savings in a spreadsheet, and that single job added over 60 hours to the running total. The total is currently somewhere above 2,400 hours saved since I started building these systems. That’s not a boast. That’s a number I find genuinely motivating when someone asks me whether the learning curve is worth it.
Connecting Scripts to Actions for a Hybrid Workflow
The cleanest production system I’ve landed on combines Photoshop scripts for the file handling and logic layer with action sets for the actual image processing. Actions are visual, shareable, and easy to modify without touching code. Scripts handle the repetitive decision-making that actions can’t. Together they cover more ground than either does alone.
If you’re building your first hybrid workflow, start with a script that simply opens every file in a folder and runs a single existing action on it, then exports and closes. That alone will change how you work. Once you see it running, you’ll know exactly what you want to add next.
The best automation system is the one that removes the decisions you’re tired of making so you have more energy for the ones that actually require your judgment.
Comments
Leave a Comment