I created a simple shell (zsh) script to help macOS users extract attachments (photos, videos, audio files) and URLs from their iMessages. The script pulls data directly from the Messages database (chat.db), organizes attachments into folders named after each contact or group conversation, and compiles all shared links into CSV files.

This tool can be useful for anyone looking to back up or organize files shared over iMessage without needing the entire conversation history. It also handles macOS's complex local storage structure for attachments.

No sign-ups or dependencies beyond macOS and SQLite. Just run the script, and it’ll create a neat export folder on your desktop. Would love feedback on any edge cases you encounter!

  • ata_aman 4 days ago |
    Awesome, thanks for this. Thinking of doing the same for Mail?

    I was using a DB product to extract iMessages for years and I lost it when I got a new Mac, this is perfect.

    • somefries 4 days ago |
      Not yet! Great idea though. I've always just pulled out my conversations without pulling the attachments or URLs. The next version might provide an option for what you want to extract (Messages, Attachments, URLS)

      I'll mess with Mail after that!

      Thanks for the love @ata_aman !

  • johng 4 days ago |
    I was unable to access this via iTerm and had to find instructions to allow iTerm to access this folder. This URL helped and then the utility worked great. Thank you for this, this is so handy.

    https://stackoverflow.com/questions/54581085/library-message...

  • johng 4 days ago |
    Suggestion: The folders are the phone number. Is it possible to use the contact name for the folder name instead of the number, if it is a known contact/in the address book? Also, what about .heic support?
  • css 3 days ago |
    If you want something a bit more robust and cross-platform, including support for the undocumented TypedStream-stored text data, you can use my open source software: https://github.com/ReagentX/imessage-exporter