The day I finally learned to write a Photoshop script, I had just spent seven hours doing the same crop-and-resize operation 200 times. Same canvas size, same anchor point, same export settings. Two hundred times. By hand. I was a working photographer with a decade of studio experience, and I had burned an entire Tuesday doing something a decent script could have finished before my morning coffee cooled down.

That was the turning point. Actions were already part of my toolkit, but I started to understand they had a ceiling. Scripts don’t.

What Actions Can’t Do That Scripts Can

Photoshop actions are recordings. They replay a fixed sequence of steps in the exact order you performed them. That’s powerful for plenty of tasks, but actions can’t make decisions. They can’t look at a filename, check an image’s dimensions, read a text file, or behave differently based on what they find. They’re a tape deck. Scripts are a brain.

Photoshop’s scripting engine supports JavaScript, AppleScript, and VBScript. JavaScript is the one worth learning because it runs cross-platform and the documentation, though dense, is thorough. What you’re really doing when you write a Photoshop script is using the app’s DOM (Document Object Model) to access and manipulate every element of a file programmatically. Layers, channels, guides, export settings, document properties, everything is an addressable object. You can loop through 500 files, apply different logic to each one based on metadata or filename, and export results to different folders, all without touching a single keyboard shortcut.

The Specific Script Structure That Changed My Production Work

The script format I use for most batch jobs follows a simple three-part architecture: open, process, export and close. In JavaScript, that looks like targeting app.open() with a file path, running your processing functions on app.activeDocument, then calling doc.exportDocument() with an export options object before closing without saving.

The part most tutorials skip is the export options object. For JPEG output, you instantiate a new ExportOptionsSaveForWeb() object, set .format to SaveDocumentType.JPEG, .quality to something between 70 and 85 for web-optimized product images (I use 78 as my default for e-commerce clients), and .optimized to true. Then you call doc.exportDocument(outputFile, ExportType.SAVEFORWEB, exportOptions). Doing this inside a loop that iterates over every file in a source folder gives you a complete batch processor in under 40 lines of code.

The loop itself uses Folder.selectDialog() to let the user pick a source folder, then sourceFolder.getFiles("*.psd") to build the file array. From there it’s a standard for loop. That’s the whole engine.

Combining Scripts With Actions for Real Leverage

Here’s where things get interesting for people who already have a solid actions library. You can call a Photoshop action from inside a script using app.doAction("Action Name", "Action Set Name"). This means you can use scripting as the decision-making and logistics layer while keeping your polished, tested actions doing the actual image work.

My current e-commerce workflow does exactly this. The script handles file ingestion, checks whether the document’s short edge is at least 2000 pixels (a minimum I’ve agreed to with most clients), renames the output file based on a SKU pulled from the source filename using a regex match, and calls one of three different actions depending on whether the product category is apparel, footwear, or hard goods. Each of those actions handles its own background treatment and sharpening pass. The script just routes traffic. Clean separation of concerns, and I can update the actions without touching the script logic.

The Afternoon That Made the Business Case For Me

A few years into running my consultancy, I picked up a contract from a mid-size apparel brand that needed 500 product shots processed and delivered within 48 hours. The images were consistent in lighting and styling, but each needed background removal verification, a specific canvas resize to 2400 x 3000 pixels, a 12-point sharpening pass, and export to both a 2400px master JPEG at quality 85 and a 800px web version at quality 72. Two files per image, 1,000 deliverables total.

I spent about three hours on a Saturday afternoon building and testing the script. By Sunday morning I had run the full batch twice (once as a test pass on 20 images, once on the full set), caught one edge case where a filename contained a space that broke my regex, fixed it in under 10 minutes, and delivered everything by Sunday evening. That job paid $3,200. I tracked the actual hands-on time at 6.5 hours including QA review of a 10% random sample.

Without the script, conservative estimate: 35 to 40 hours of production work. That gap is not abstract. That’s the difference between a business that scales and one that grinds you into the floor.

Where to Start if You’ve Never Written a Script

Open Photoshop’s Script Events Manager under File > Scripts and get familiar with what’s already there. Then find the Photoshop Scripting Guide in Adobe’s developer documentation. It’s a PDF, it’s dry, but pages 30 through 60 covering the Application and Document objects will give you the foundation for 90% of practical batch work.

Write your first script to do exactly one thing: open a single file, resize it to 1200 x 1200 pixels at 72 dpi, and save a JPEG to your desktop. Get that working. Then put it in a loop. Then add a folder picker. Build it in layers, test at each stage, and resist the urge to write something complex before you understand the basics.

The investment is maybe 10 hours of uncomfortable learning. What you get back is every repetitive task you will ever face in your career.