My First Apple Script

Reading Time: < 1 minutes

Let me begin by saying this: I was today years old when I learned that Apple Script is a thing – and it’s easy to use.

So what did I do? Well, I needed a way to batch export images to the webp format with Pixelmator. And after some querying the web using the Lord of Hell for web searches (aka Google) I found something like this – I had to modify it to fit my needs:

tell application "Pixelmator Pro"
	set exportLocation to choose folder with prompt "Please select where you'd like export the images:"
	repeat (number of documents) times
		export the front document to file ((exportLocation as text) & (name of the front document) & ".webp") as WEBP with properties {compression factor:85}
		close the front document without saving
	end repeat
end tell

And that way all open images in Pixelmator Pro will be exported to webp files with a compression factor of 85. After the export happened the original images will be closed without saving.

And that’s really all there is to it.

There’s a basic introduction how to use Apple Script with Pixelmator Pro on their website