Here is a functional example of a custom command. You have a document in the Finder that has its extension hidden, and you do not want to Get Info, and click unhide. Instead, you speak “show extension,” and dictation instantly unhides the document extension.
Here is the AppleScript that I have placed in an Automator Workflow's Run AppleScript action. This workflow can be saved anywhere in your home directory, or subfolder, as long as you can find it later.

tell application "Finder"
activate
-- document icon must be selected, and extension must be hidden
if not selection is {} and extension hidden of (selection as text as alias) is true then
set thisFile to selection as text as alias
set thisName to name of thisFile
set theNameExt to name extension of thisFile
set theBaseName to text 1 thru ((offset of "." & theNameExt in thisName) - 1) of thisName
if extension hidden of thisFile is true then
set extension hidden of thisFile to false
end if
say "File Extension restored to " & theBaseName & " dot " & theNameExt
else
sayuser_mistake
return
end if
end tell
tell application "SpeechRecognitionServer" to if it is running then quit
return
In System Preferences : Accessibility : Dictation : Dictation Commands…
- Click + to add a new command.
- Configuration
- When I say: Show Extension
- While using: Finder
- Perform: Select Run Workflow : Other... <locate, and click on the above Workflow file>, then click Open.
- Ignore Save Workflow As…
- Click the check box next to your as yet unnamed command, and it will become the When I Say string.
- Click Done.
- Launch Dictation. Select a File without its extension showing, and speak your command. If your audio is on, it will speak that the file extension has been restored to the filename.
- You may need to visit System Preferences : Security & Privacy : Privacy : Accessibility to enable Automator, or Script Editor authorization.