REI Newsprint Ad Automation
A script that automatically generates newspaper ads. Saving time and money by letting our computer overlords do all the work.
One of the first programs I ever wrote saved my company more than $12,000.
It was the fall of 2014 and I had just gotten hired on at REI. In those days REI bought a lot of ads in lots of newspapers. A typical ad campaign could have as many as 150–300 ads, and it was my job to make sure they were all the right size. I would take a design, resize the page, nudge the logo to the left, and repeat. Like sands through an hour glass, so slipped my sanity.
In need of some relief, I turned to a small but painful point in the process: The very last step. Save a PDF of all the ads, split them out individually, and rename every file. I practically wore the Command and C keys off my keyboard. I decided that if I could figure out how to get the computer to do this tedious work for me, I could spend my time on more valuable things, like resizing and nudging.
Buried deep in my Mac’s Applications folder, I found a program called Script Editor. It’s a development tool for writing automated scripts in languages like AppleScript. AppleScript has been around since the early 90s and is great for repetitive tasks and automation. It’s written in a natural style that is perfect for someone who likes to talk to his phone like some sort of lunatic. (You my girl, Siri!)
display dialogue "I like turtles."
After a few tutorials and much trial and error, I cobbled together a working program. It wouldn’t win any Lil’ Miss pageants, but it worked, dammit! I’d give it the pdf with all the ads and a list of filenames, and they’d all individually show up in a folder with a bow on it, minus the bow.
Not content with just saving the “C” key, I wanted to save my arrow keys as well. I started digging a little further to see if you can just automate the whole damned process. SPOILER ALERT: You can!
The following week I slowly worked my way through writing a script. Can I resize a page? Can I override a master page? If I have two different master pages, how do I apply the right one? How do I keep all the elements anchored to the right spots? Why is the order of all the elements fucked up? How do I give it a list of sizes? How do I add a progress bar? Were all those errors really caused by a missing semicolon!?
After failing thousands of times, I finally worked my way to a test: Could I take an old job and recreate the 150 versions I had done by hand? I set up my files, set up the layout constraints, and clicked run. The program churned. The screen moved on its own. The progress bar started filling up. A few minutes later the script was done. I had 150 ads with everything in the right place. A process that had once taken me 3 days now took me 3 minutes.
Even better: I discovered that the whole time I had been working on it, REI had been looking for an outside vendor to create a script to do exactly the same task. The budgeted cost of that script? $12,000.
These days, REI has shifted most of its advertising spend away from print, so I’ve had less use for my script. But, more than saving me time and them money, it provided a catalyst for me to start building things, to start solving real problems. I no longer have to settle for “wouldn’t it be cool if?” — I can make things. And while I’ve gone on to learn new languages and designed and developed more programs, it’s like they always say, you never forget your first.