Skip to content

Instantly share code, notes, and snippets.

@lexrus
Last active January 26, 2024 16:12
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save lexrus/f4597852bce78daf1e833bf0eed98d13 to your computer and use it in GitHub Desktop.
Save lexrus/f4597852bce78daf1e833bf0eed98d13 to your computer and use it in GitHub Desktop.
Delete all iMessage conversations. Compatible with macOS Monterey. Please check Reduce motion before launch this apple script.
# System Preferences -> Accessibility -> Display -> Reduce motion
tell application "Messages" to activate
tell application "Messages"
set chatCount to (count of chats)
end tell
tell application "System Events"
tell process "Messages"
set frontmost to true
repeat chatCount times
click menu item "Delete Conversation…" of menu "File" of menu bar 1
delay 0.2
click button "Delete" of sheet 1 of window 1
delay 0.2
try
click button "Report Junk" of sheet 1 of window 1
delay 0.2
on error errMessage number errNumber
end try
click menu item "Go to Next Conversation" of menu "Window" of menu bar 1
delay 0.2
end repeat
end tell
end tell
@lexrus
Copy link
Author

lexrus commented Nov 27, 2021

@iconifyit
Copy link

Nice work. This was the missing piece for a similar script I was working on. I hacked together some Python scripts to do some extra work like caching and searching contacts to only delete unknown callers. WARNIN: THIS IS NOT TESTED CODE -> It's kind of a mess. I wrote it to just clear my old chats and have not had a chance to "product-ize" it yet but anyone is welcome to use it. https://github.com/iconifyit/batch-delete-imessages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment