Play a sound when AppleScript is done

Just to complement @adamh and @DigiMonk's excellent answers:

Good old beep can do the job if the default sound will do:

beep  # beep once

If once isn't enough, simply specify the desired number of beeps as an argument:

beep 2 # beep twice.

Incidentally, beep, say, and display notification are all defined in the User Interaction suite of dictionary StandardAdditions.sdef. To see these definitions, select File > Open Dictionary... in AppleScript Editor, and, in the list that pops up, select StandardAdditions.osax.


You can play a random sound too!

do shell script "afplay /System/Library/Sounds/" & some item of paragraphs of ((do shell script "ls /System/Library/Sounds/")) ---random sound

You can use afplay :

do shell script "afplay /Users/john/Sounds/vengabus.aiff"

or i like to use text to speech:

say "Finished!"

The notification center (probably OS X 10.9.x only) can display messages with a sound.

set variableWithSoundName to "Glass"
display notification "Upload complete" with title "Screenshot" subtitle "Status" sound name variableWithSoundName

-- "sound name" is the name of a sound located in "~/Library/Sounds"
--  or "/System/Library/Sounds"

The display notification command is from the StandardAdditions.

(…and there is also the command beep which plays the default alert sound and takes the number of "beeps" as argument)

Tags:

Applescript