Skip to content

Mac Automation Scripting Guide: Calling Command-Line Tools — by Apple Developer Documentation

intermediatepageLink only (©)

Apple's guide to running shell commands from AppleScript with do shell script, including building a command by concatenation and why paths with spaces break unless wrapped with quoted form of. This is an archived page, so details may predate current macOS.

Quick steps

  1. do shell script "ls /Applications/"
  2. Wrap paths with quoted form of to survive spaces

Paraphrased from the source. Menus can differ by version, so check the original for full details.

Read the full article on developer.apple.com

Source: Mac Automation Scripting Guide: Calling Command-Line Tools by Apple Developer Documentation. Licence: Link only (©).

Source reviewed
2026-11-02
Link checked
2026-11-02
Tested hands-on
Not by Oddbyte.Me

applescriptdo shell scriptautomationquoting

More in AppleScript & Shortcuts

AppleScript, Do Shell. How do I write the 'test' command to the 'script editor'? — by Quinn "The Eskimo!" (Apple DTS) on Apple Developer Forums

intermediateforum

Apple's DTS engineer explains that do shell script throws an AppleScript error whenever the command exits non-zero (so test -d on a missing folder errors), shows try blocks to handle it, multi-line scripts, and quoted form of POSIX path for safe paths. He also suggests avoiding the shell where System Events can do the job.