• Stars
    star
    166
  • Rank 227,090 (Top 5 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Exports iMessages and SMS's to files.

OSX Messages Exporter

Exports Messages' conversations to HTML files. This includes iMessages, SMSs, and group conversations. The simplest way to run it is this:

php messages-exporter.php -o ~/Desktop/Messages/

After it finishes, you'll have an HTML backup of the messages on your computer in a folder called "Messages" on your Desktop.

This script processes all of the existing conversations in the Messages app, logs them to a separate backup database in your specified output directory, and then generates HTML files for each conversation, mimicking the look and feel of Messages conversations:

A screenshot of the chat representation produced by OSX Messages Exporter

See example.html to inspect the HTML generated by OSX Messages Exporter that produce the screenshot above.

Attachments are saved in a separate directory for each conversation.

It will try and match phone numbers and email addresses to real names, using your Mac's Address Book. It should be able to find contacts that are stored either on your Mac or in iCloud, if they've had time to sync to your Mac (typically only a few minutes).

Note that if you are running OSX Mojave or later, you will probably need to give Terminal full disk access in order for OSX Messages Exporter to work.

With the -f or --flush option, you can force the script to delete the existing backup database and regenerate everything. (Without this option, you could maintain backups of conversations even if Messages deletes them, accidentally or not.)

With the -r or --rebuild option, you can regenerate the HTML files from the backup library.

With the -d or --database option, you can run the export on a specific Messages database file. By default, the script uses ~/Library/Messages/chat.db. Note that when using this option, attachments will not be saved, since the assumption is that the paths to the files are from another machine.

With the --date-start and --date-stop options, you can limit the dates that are added to your backup. Note that this only applies to new messages being exported; it won't remove messages outside of those dates that have already been exported.

With the --path-template option, you can define the format of the exported HTML filenames (as well as the date range for each individual file). The string _CHAT_TITLE_ will be replaced by the chat title (usually just the name of the other participant), and any strftime-style placeholders will be replaced by the appropriate values for the chat's time period. For example, if you set --path-template "%Y-%m-%d - _CHAT_TITLE_", then each exported HTML file will contain at most one day of messages, and they would have names like "2021-06-11 - Alex Smith.html".

Usage

$ messages-exporter.php [-o|--output_directory output_directory]
                        output_directory: a path to the directory where the messages should be saved. Save files in the current directory by default.
                        [-f|--flush]
                        Optionally, flush the existing backup database, essentially starting over from scratch.
                        [-r|--rebuild]
                        Optionally, rebuild the HTML files from the existing database.
                        [-d|--database /path/to/chat/database]
                        Optionally, specify an alternate database file if, for example, you're running this script on a backup of chat.db from another machine.
                        [--date-start YYYY-MM-DD]
                        Optionally, specify the first date that should be queried from the Messages database.
                        [--date-stop YYYY-MM-DD]
                        Optionally, specify the last date that should be queried from the Messages database.
                        [-t|--timezone "America/Los_Angeles"]
                        Optionally, supply a timezone to use for any dates and times that are displayed. If none is supplied, times will be in UTC. For a list of valid timezones, see https://www.php.net/manual/en/timezones.php
                        [-p|--path-template "%Y-%m-%d - _CHAT_TITLE_"]
                        Optionally, supply a strftime-style format string to use for the exported chat files. **Use _CHAT_TITLE_ for the name of the chat.** For example, you can separate your chats into yearly files by using `--path-template "%Y - _CHAT_TITLE_"` or monthly files by using `--path-template "%Y-%m - _CHAT_TITLE_"`. You may also wish to use the date as a suffix so that chats from the same person are all organized together in Finder, in which case you might use `--path-template "_CHAT_TITLE_ - %Y-%m-%d"`
                        [--match "Conversation Title"]
                        Limit the output to conversations that include this argument somewhere in their title.
                        [--match_regex "/^Conversation Title$/"]
                        Limit the output to conversations whose titles match this regular expression.

Caveats

  • If you run the script, and then delete a conversation in Messages, and then run the script again, the backup of the deleted conversation will not be deleted. This is by design.
  • If you try to run this script via a LaunchAgent or some other automated means, it may fail because the Messages database file is protected by Full Disk Access starting in Mac OS Mojave. To get around this, you'll need to do the following:
    • Create a shell script that runs OSX Messages Exporter, like this:
      #!/bin/bash
      php /path/to/OSX-Messages-Exporter/messages-exporter.php -o /path/to/output
    • Package that script into an app using Platypus
    • Give the app Full Disk Access
    • Modify your LaunchAgent (or other automated script) to run the app instead of running OSX Messages Exporter directly.

Questions?

Email me at [email protected].

Props

Thanks to Garvin Hicking (@supergarv on Twitter) for fixes and improvements.

More Repositories

1

Typo.js

A client-side JavaScript spellchecker that uses Hunspell-style dictionaries.
JavaScript
502
star
2

LEGO.scad

An OpenSCAD LEGO-compatible brick generator.
OpenSCAD
197
star
3

Channel-Two

Channel Two: Run your own television network in the browser.
JavaScript
134
star
4

OpenSCAD-Dovetails

A library for generating dovetail tails and pins in OpenSCAD.
OpenSCAD
42
star
5

3D-Prints

Miscelleneous 3D prints and models.
OpenSCAD
34
star
6

Retweet

A script that republishes any tweets that start with "@username", where “username” is an arbitrary username that you supply.
Python
15
star
7

Garbage-Cabinet

A customizable tilt-out garbage cabinet.
OpenSCAD
14
star
8

Blog-Helper

Blog Helper is a Alexa skill that provides a voice interface for WordPress.com blogs
PHP
13
star
9

Keyring-Facebook-Importer

A Facebook importer for use with the Keyring and Keyring Social Importers WordPress plugins.
PHP
13
star
10

PHP-GEDCOM-Tools

PHP scripts for interacting with GEDCOM files.
PHP
12
star
11

RSS-Ticker

RSS Ticker loads your Firefox Live Bookmarks and scrolls their entries across your screen while you surf.
JavaScript
7
star
12

Comment-Snob

Comment Snob is a browser extension that filters out undesirable comments from comment threads on the Web.
JavaScript
6
star
13

AutoAuth

JavaScript
6
star
14

Clockback

Clockback is the Web frontend and upload script for a basic open-source Timehop replacement.
PHP
6
star
15

Dropseeker

Transcribe podcasts to make them searchable, and then extract audio clips based on search terms.
PHP
5
star
16

googlecode2github

A script to import support issues from a Google Code project to a Github project.
Python
5
star
17

Feed-Sidebar

The Feed Sidebar is an extension for Firefox that displays the items from your Live Bookmarks in the sidebar.
JavaScript
5
star
18

ChroSh

The Google Chrome Shell
5
star
19

Telegraph.js

Telegraph.js is a JavaScript library that enables Morse code input on text fields.
JavaScript
5
star
20

Formategory

A WordPress plugin that formats posts based on their categories.
PHP
4
star
21

anyMail

anyMail was an IMAP Web e-mail client I wrote during an independent study course in college. I'm publishing the code for posterity; you really shouldn't use it.
PHP
4
star
22

Better-Omnibox

Better Omnibox improves the relevance of Chrome's Omnibox results.
4
star
23

Rite-Track-Compatible-Hardware

3D models of a drawer component socket and case runner guide compatible with the Kenlin Rite-Trak drawer track system.
OpenSCAD
4
star
24

iPhoto-Disc-Export

Export your iPhoto library as a browseable website that can be burned to a disc and remain completely functional offline or uploaded and served from a website.
PHP
4
star
25

Keyring-Reddit-Importer

Import Reddit posts and comments.
PHP
3
star
26

Keyring-River

WordPress theme based on David Hariri's 'river' project.
PHP
3
star
27

Name-Exchange

3
star
28

pyTiVo-Utilities

Python
3
star
29

Tab-History-Redux

Causes links opened in a new tab in Firefox retain their history.
JavaScript
3
star
30

OPML-Support

OPML Support is a Firefox extension that adds support for importing and exporting bookmarks in OPML format.
JavaScript
3
star
31

New-Tabs-At-End

Makes new tabs open at the end of the tab strip in Chrome.
2
star
32

Facebook-Email-Links

Converts plain-text email addresses in Facebook profiles to mailto: links.
JavaScript
2
star
33

Ryuki

A child theme of the Ryu WordPress theme that modifies the front page to show content from featured categories.
PHP
2
star
34

Reenact

An app for reenacting photos.
JavaScript
2
star
35

URL-Fixer

URL Fixer is a Firefox extension that automatically corrects typographical errors in URLs typed in the Firefox Location Bar.
JavaScript
2
star
36

TwitterBar

TwitterBar allows you to post to Twitter from Firefox's address bar.
JavaScript
2
star
37

Inline-Preview

Inline Preview is a plugin for WordPress that adds a zoomed out preview of the current post next to the post editor when the user clicks Preview instead of opening in a new tab.
JavaScript
2
star
38

Clean-and-Sober

A clean (and sober) WordPress theme.
PHP
2
star
39

Translate

Small extension that either translates: web pages (via toolbar button) or selected text (via context menu) from several foreign languages into English, as well as 12 other languages.
JavaScript
2
star
40

BeardTracker

A webapp to track your beard's progress from peach fuzz to man fur.
1
star
41

anyInventory

anyInventory was the Web's most flexible inventory system in 2004.
PHP
1
star
42

YouTube-Comment-Snob

An intelligence filter for YouTube's comment section.
JavaScript
1
star
43

scribefire-chrome

Automatically exported from code.google.com/p/scribefire-chrome
JavaScript
1
star
44

StopMotion

Stops the auto-play of DailyMotion videos.
JavaScript
1
star
45

GlotPress-Chrome-Extension-Support

Extend GlotPress to support Chrome-style messages.json locales.
PHP
1
star
46

Akisbot

Akisbot is alive.
OpenSCAD
1
star
47

Farmhouse-Table

Customizable plans for a farmhouse-style table.
OpenSCAD
1
star
48

Do-Today

A lightweight chore-tracking web app.
PHP
1
star
49

Deepgram-PHP

An unofficial PHP SDK for Deepgram's API.
PHP
1
star
50

Solar-System

An OpenSCAD animation of the solar system.
OpenSCAD
1
star
51

Slashdotter

Slashdotter is a Firefox extension that makes it easier (and more fun!) to use Slashdot.org.
JavaScript
1
star
52

Tapsure

A browser extension that allows you to tap your passwords.
JavaScript
1
star
53

True-Colors

True Colors is a Firefox extension that bleeds the colors from the web page you're viewing into the tab bar and status bar. Think of it as Ambilight for your browser.
JavaScript
1
star
54

Interpr.it

Interpr.it is a collaborative tool for browser extension developers and bi-lingual extension users.
PHP
1
star
55

Plain-Text-Links

Plain Text Links is a Firefox extension that allows you to open plain-text URLs as links via the context menu.
JavaScript
1
star
56

iPhoto-WordPress-Export

Export your iPhoto library to a WordPress website.
PHP
1
star
57

Halftone

Halftone is an app for making halftone-style carves with Inventables's Easel CNC design platform.
JavaScript
1
star
58

Facebook-Image-to-Email

A Firefox extension that decoded the images that Facebook used to use to display email addresses.
JavaScript
1
star
59

WATE

WATE (Web Advanced Text Editor) is a Web-based text editor for use in instances when X-forwarding is not feasible (or possible), and a terminal editor hinders code production.
JavaScript
1
star
60

Speedlapse

Speed up videos with ffmpeg according to a curve (or any function).
PHP
1
star
61

Twitter-Filter

A browser extension that allows you to filter out Twitter updates based on their source.
JavaScript
1
star
62

Links-Like-This

Links Like This is a Firefox extension that helps you to open sets of similar links in tabs at once.
JavaScript
1
star
63

Photos-Only

A WordPress plugin that automatically shows all of your uploaded images as published posts, no extra steps required. Just upload to the media library.
PHP
1
star
64

TubeStop

TubeStop is a Firefox extension that prevents YouTube videos from playing automatically, whether you are viewing them on YouTube.com or via a third-party site that is embedding them.
JavaScript
1
star
65

Alexa-Rock-Jar

This skill allows you to keep virtual voice-controlled rock jars. A rock jar is a method for tracking children's behavior. Rocks are added for good behavior and removed for bad behavior. When the jar is full (or reaches a certain number of rocks), the child can exchange the rocks for a reward.
PHP
1
star
66

Alexa-Bored

This is an Alexa skill that gives you (or your kids) ideas for things to do when you (or your kids) are bored.
PHP
1
star