Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created November 19, 2024 10:51
Show Gist options
  • Save OKsign/fa3e312982c0ff422194239bc8816794 to your computer and use it in GitHub Desktop.
Save OKsign/fa3e312982c0ff422194239bc8816794 to your computer and use it in GitHub Desktop.
-- Important Note: This script will delete all files in the target folder including CloudRecordings.db, CloudRecordings.db-wal and CloudRecordings.db-shm. I assume those 3 files are about iCloud so if you use iCloud for Voice Memos, don't use this script. If you don't use iCloud for Voice Memos, what you should do is create multiple recordings for testing this script then test it. In the future, something may change this script might not work. You should prepare for that.
if application "VoiceMemos" is running then
tell application "VoiceMemos" to quit
end if
set info to system info
set userName to short user name of info
set upath to "/Users/" & userName & "/Library/Group Containers/group.com.apple.VoiceMemos.shared/Recordings"
set tar_path to quoted form of POSIX path of upath
do shell script "open " & tar_path
delay 1.2
tell application "Finder"
set winName to (name of front Finder window)
end tell
if winName is "Recordings" then
tell application "System Events"
keystroke "a" using command down
delay 2
key code 51 using command down
delay 3
keystroke "w" using command down
end tell
tell application "VoiceMemos" to launch
display notification "Delete All Recordings in Voice Memos" with title "Done!"
else
delay 3
tell application "Finder"
set winName to (name of front Finder window)
end tell
if winName is "Recordings" then
tell application "System Events"
keystroke "a" using command down
delay 2
key code 51 using command down
delay 3
keystroke "w" using command down
end tell
tell application "VoiceMemos" to launch
display notification "Delete All Recordings in Voice Memos" with title "Done!"
else
display dialog "You should do it yourself because the script waited too long for the target window." with title "Delete All Recordings in Voice Memos"
end if
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment