← Back to home

May 29, 2026

AppleScript Programming: Practical Automation Use Cases That Still Make Sense

A modernized look at AppleScript: simple macOS automation, shell commands, Finder workflows, dialogs, UI scripting, and practical testing-related use cases.

AppleScript is one of those scripting languages that people do not talk about much anymore.

And honestly, I understand why.

It looks old. It feels strange if you are used to Java, Python, JavaScript, Bash, or pretty much any modern programming language. The syntax is close to plain English, but at the same time it can be weirdly picky. So yes, AppleScript is not exactly the coolest technology in the room.

But here is the important part: it is still useful.

AppleScript has been around since 1993, originally introduced as part of System 7, and it has been part of the Mac ecosystem for decades. That alone makes it interesting. Apple removed, replaced, redesigned, and rebranded a lot of things over the years, but AppleScript somehow survived.

Personally, I like AppleScript because it gives you a simple way to automate macOS itself. Not just files. Not just terminal commands. Actual Mac applications, dialogs, Finder actions, and sometimes even UI flows.

For testing, small productivity scripts, file management, and old-school automation, it can still be a pretty powerful tool.

So let’s look at practical use cases where AppleScript still makes sense.


1. Saying Text or Phrases

This is probably the simplest AppleScript example, but it is also a fun one.

You can make your Mac say any text using one command:

say "Automation finished"

That is it.

Real-world usage examples:

For example:

say "The build is complete"

Is this necessary? No.

Is it useful sometimes? Absolutely.

Especially when you run a script, switch to another task, and want your Mac to tell you when something is finished.


2. Executing Shell Commands

This is one of the best AppleScript features.

You can combine AppleScript with normal Unix shell commands.

The syntax looks like this:

do shell script "ls"

For example, let’s store the output of a shell command in a variable and show it in a dialog:

set theOutput to do shell script "ls"
display dialog theOutput

This is where AppleScript becomes more interesting.

You are not limited to AppleScript itself. You can run shell commands, capture the result, and then use macOS UI features to show dialogs, ask questions, or trigger other actions.

For example:

set currentUser to do shell script "whoami"
display dialog "Current user: " & currentUser

Real-world usage examples:

For a QA engineer or automation engineer, this can be surprisingly handy. You can run a command in the background and show the result in a native macOS dialog without building a full application.


3. Showing Dialogs

AppleScript can show simple native dialogs very easily.

display dialog "Hello from AppleScript"

You can also add buttons:

display dialog "Do you want to continue?" buttons {"Cancel", "Continue"} default button "Continue"

This is useful when you want a simple interactive script.

No GUI framework. No SwiftUI. No JavaFX. No Electron monster with 300 MB of dependencies.

Just a small script.

Real-world usage examples:

Example:

set theAnswer to button returned of (display dialog "Clean Downloads folder?" buttons {"No", "Yes"} default button "No")

if theAnswer is "Yes" then
    display dialog "Cleaning started"
end if

It is not fancy, but it works.


4. Asking for User Input

AppleScript can also ask the user to enter text.

set theResponse to display dialog "What is your name?" default answer ""
display dialog "Hello, " & (text returned of theResponse)

This is one of the most common AppleScript patterns.

You ask something, store the result, and then use it in your script.

Example:

set folderName to text returned of (display dialog "Enter folder name:" default answer "New Folder")
do shell script "mkdir -p ~/Desktop/" & quoted form of folderName

Real-world usage examples:

For small developer tools, this is really useful.

You can make a script that asks for a project name, creates folders, opens the editor, and starts a local server. It is not a replacement for a serious CLI tool, but for personal workflows it is great.


5. Automating Finder

Finder automation is one of the classic AppleScript use cases.

For example, you can empty the Trash:

tell application "Finder"
    empty trash
end tell

The syntax is almost plain English.

You can also open folders:

tell application "Finder"
    open folder "Downloads" of home
end tell

Or create a new folder:

tell application "Finder"
    make new folder at desktop with properties {name:"Test Folder"}
end tell

Real-world usage examples:

For example, you can create a testing folder on the Desktop:

tell application "Finder"
    make new folder at desktop with properties {name:"QA Test Results"}
end tell

This is simple, but that is exactly the point.

Sometimes you do not need a serious tool. You just need to automate boring clicks.


6. Batch Renaming Files

This is where AppleScript becomes genuinely useful.

Let’s say you have a folder with screenshots, logs, or exported files, and you want to rename them with a common prefix.

set filePrefix to text returned of (display dialog "Enter file prefix:" default answer "test")

tell application "Finder"
    set selectedFiles to selection
    set counter to 1

    repeat with currentFile in selectedFiles
        set name of currentFile to filePrefix & "-" & counter & ".png"
        set counter to counter + 1
    end repeat
end tell

Real-world usage examples:

This is the kind of automation that saves small amounts of time repeatedly.

And that is usually where automation wins.

Not in some dramatic “AI will replace everything” way.

Just by removing boring repetitive work.


7. Opening Apps and Preparing a Workspace

AppleScript can launch applications and prepare your working environment.

tell application "Safari" to activate
tell application "Terminal" to activate
tell application "Finder" to activate

You can use this to create a workspace setup script.

For example:

tell application "Safari"
    activate
    open location "https://github.com"
end tell

tell application "Terminal"
    activate
end tell

tell application "Finder"
    open folder "Projects" of home
end tell

Real-world usage examples:

This is especially useful when you often start the same set of apps and pages.

Instead of clicking everything manually, you run one script.


8. Working with Browser Tabs

AppleScript can interact with some browsers, especially Safari, pretty nicely.

Example:

tell application "Safari"
    activate
    open location "https://www.apple.com"
end tell

You can open multiple URLs:

tell application "Safari"
    activate
    open location "https://github.com"
    open location "https://developer.apple.com"
    open location "https://www.apple.com"
end tell

Real-world usage examples:

For example, if you are testing your website, you can create a script that opens the homepage, articles page, projects page, and contact page.

tell application "Safari"
    activate
    open location "https://example.com"
    open location "https://example.com/articles"
    open location "https://example.com/projects"
    open location "https://example.com/contact"
end tell

Of course, this is not a replacement for Selenium, Playwright, or Cypress.

But for quick manual testing preparation, it is convenient.


9. Showing Notifications

Dialogs are useful, but sometimes they interrupt too much.

AppleScript can also show macOS notifications:

display notification "Tests finished" with title "Automation"

You can also combine this with shell commands:

set testResult to do shell script "echo Passed"
display notification testResult with title "Test Result"

Real-world usage examples:

This is a very practical use case.

Instead of constantly checking the terminal, you let the system tell you what happened.


10. Basic UI Scripting with System Events

This is where AppleScript becomes both powerful and dangerous.

You can use System Events to interact with UI elements.

Example:

tell application "System Events"
    keystroke "n" using command down
end tell

This simulates pressing Command + N.

You can also type text:

tell application "System Events"
    keystroke "Hello from AppleScript"
end tell

Real-world usage examples:

For example:

tell application "TextEdit"
    activate
end tell

tell application "System Events"
    keystroke "n" using command down
    keystroke "This text was typed by AppleScript"
end tell

This can be useful for testing, but you need to be careful.

UI scripting depends on focus, timing, permissions, and the current state of the application. If the wrong window is active, your script may type into the wrong place.

So I would not build serious test automation around this.

But for small desktop automation tasks? It works.


11. Running Simple Test Helpers

AppleScript can be useful for QA work, not as a replacement for proper test automation, but as a helper.

For example, you can create a small script that:

Example:

display dialog "Starting test environment..."

do shell script "cd ~/Projects/my-app && npm test"

display notification "Test command finished" with title "QA Helper"

Or with a Maven project:

display dialog "Running Maven tests..."

set testOutput to do shell script "cd ~/Projects/my-java-project && mvn test"

display dialog testOutput

This is not the best way to run serious CI/CD pipelines, obviously.

But for local helper scripts, demos, teaching, or quick checks, it is useful.

Sometimes a small script that saves 10 clicks is enough.


12. Creating Tiny macOS Utilities

One underrated thing about AppleScript is that you can save scripts as applications.

That means you can create a tiny local utility and put it in the Dock.

For example, a script that opens your project folder:

tell application "Finder"
    open folder "Projects" of home
end tell

Or a script that runs a cleanup command:

do shell script "rm -rf ~/Downloads/*.tmp"
display notification "Temporary files removed" with title "Cleanup"

Real-world usage examples:

This is the kind of thing that feels very old-school, but also very efficient.

No cloud account. No subscription. No huge framework.

Just a small script on your machine.


13. Combining AppleScript with Shortcuts

Modern macOS has Shortcuts, and for many users it is more approachable than AppleScript.

But AppleScript is still useful because you can combine it with other automation tools.

You can use AppleScript inside bigger workflows, or use shell scripts and Shortcuts together with AppleScript-like logic.

The general idea is simple:

When you combine them, you can build useful personal automation without writing a full application.

This is the real value of AppleScript today.

Not because it is modern.

Because it is integrated.


Should You Learn AppleScript Today?

I would not recommend AppleScript as your first programming language.

I also would not recommend building a serious modern application with it.

But I do think it is still worth knowing if you use macOS seriously.

Especially if you are:

AppleScript is not trendy, but it solves real problems.

And sometimes that is more important than being trendy.


Conclusion

AppleScript is an old scripting language, but old does not automatically mean useless.

It can still help with:

For software testing, personal automation, and small productivity scripts, AppleScript is still interesting.

It is not perfect. The syntax can be strange. UI scripting can be fragile. Some apps support automation better than others.

But if you are on macOS and you like automating things, AppleScript is still worth a look.

Sometimes the boring old tool is exactly the tool you need.