32

I have a long (several months' worth) iMessage conversation with a contact. He lost these messages when he re-installed his OS, but I still have the archive. There is some important information there that we'd like to keep.

Is there a simple way to export this conversation for archival in a human readable form, and also keep any images?

I can select parts of the conversation, copy it to the clipboard and paste it into a rich text document, but this discards all images. I'm looking for a way that keeps the images.

Note: I use iMessage on OS X only, not iOS.

(Ideally I'd also like to export all non-image file attachments, but I'm not expecting that this will be possible.)

  • 1
    Do you want to save them from an iDevice or a Mac ? – Matthieu Riegler Nov 3 '13 at 19:53
  • @MatthieuRiegler A Mac. I don't use iMessage on iOS, so I didn't think of that possibility. I'll update the question. – Szabolcs Nov 3 '13 at 19:53
  • 1
    Does apple.stackexchange.com/questions/88023/… help or are you looking for something else? – nohillside Nov 3 '13 at 19:54
  • @patrix I am looking for a way to get the messages out of iMessage, so I can view them even if I stop using OS X. I realize that it was a mistake to reply on iMessage to keep important information, so I want to move away from it completely, and hopefully salvage the chatlog for the future. – Szabolcs Nov 3 '13 at 19:58
18

If you know the iMessage account of your contact here is a bash script of mine to retrieve text + images.

#Parameter is a iMessage account (email or phone number i.e. +33616.... )
if [ $# -lt 1 ]; then
    echo "Enter a iMessage account (email of phone number i.e +33616.....) "
fi
login=$1

#Retrieve the text messages 

sqlite3 ~/Library/Messages/chat.db "
select is_from_me,text from message where handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='iMessage;-;$1')
)" | sed 's/1\|/me: /g;s/0\|/budy: /g' > MessageBackup.txt


#Retrieve the attached stored in the local cache

sqlite3 ~/Library/Messages/chat.db "
select filename from attachment where rowid in (
select attachment_id from message_attachment_join where message_id in (
select rowid from message where cache_has_attachments=1 and handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='iMessage;-;$1')
)))" | cut -c 2- | awk -v home=$HOME '{print home $0}' | tr '\n' '\0' | xargs -0 -t -I fname cp fname .
11

I found a workable solution:

  1. Scroll up until all messages are loaded
  2. Print to PDF
  3. (If you have Acrobat,) crop off the margins from the pages to improve readability of split-across-pages messages.

The result doesn't look great, but it does contain all the images and the text is searchable. So it's good enough.

  • 3
    What if you have 25,000 messages in the conversation and scrolling up is not viable? – User Jan 12 '16 at 15:53
  • It takes a little time, but I think this solution is good for many use cases. – citadelgrad Jul 6 '17 at 20:29
11

I took the liberty of furthering the above answer by Matthieu. I wrote a script that would automate the process by backing up all the user's messages, including images, audio files, and movies--storing each conversation into a text file by phone number.

https://github.com/PeterKaminski09/baskup

Edit: I developed the script into an OS X app with some nice features like contact recognition. https://peterkaminski09.github.io/baskup

  • What if the contact has no phone number? – Szabolcs Jul 17 '15 at 20:15
  • 2
    I retrieve all contact info from the chat table in ./Library/Messages/chat.db. This is not specific on user phone numbers. Just their id that is associated with their messages. In most instances this is in fact a phone number. – Peter Kaminski Jul 18 '15 at 4:04
  • I used it. It worked. It was the only solution I found that didn't cost money. Thank you! – Erik Allen Sep 4 '18 at 2:21
  • I used it. It worked. Very nicely I should add. +1 'cos that's all I can give for a single answer. – Seamus Sep 18 '18 at 19:27
6

Archiving

This person appears to have a more polished solution (no disrespect intended to the extremely useful SQLite scraper above):

http://www.chrisfinke.com/2013/11/05/convert-ichat-transcripts-to-useable-xml/

To summarise the blog:

  • install Adium
  • choose the "import from iChat" option
  • Adium transcripts are generated from your logs and stored in:

    ~/Library/Application Support/Adium 2.0/Users/Default/Logs/

The converted files are in HTML, more easily readable and hopefully more archive-friendly, but the sqlite approach to attachment linkage looks sensible.

Attachments

Note that iMessage attachments tend to live in:

~/Library/Containers/com.apple.iChat/Data/Library/Messages/Attachments/...

(I don't know the rules for what goes in there and what doesn't, so it might not be complete - but there's a fair amount in there)

But actually you can see some information about the contact and conversation in the file's extended attributes:

$ xattr -lp com.apple.metadata:kMDItemWhereFroms <attachment>

will print an origin if Messages put one there on download.

  • 1
    Yes, @Szabolcs, I did see the "please don't spend your time on this any more" comment, but had to do a bit of digging of my own so thought I ought to share in case it's useful to someone else. – gra May 6 '14 at 18:10
0

Your mac should automatically save them. Here are instructions on how to extract them:

http://www.imore.com/how-view-and-move-your-imessage-history-and-attachments

  • 1
    Welcome to Ask Different! Please don't give link-only answers. We're looking for answers that provide explanations of why it answers the question. Links can change over time and then we'll lose the question-answer context. See How to Answer for info on what makes up a good answer. - From Review - – fsb May 27 '16 at 0:18
-1

Export iMessages app allows you to save, print, backup and recover SMS/iMessages to your Mac/PC.

  • 1
    This doesn't really answer the question as I explicitly said that I use iMessage only on OS X, not on iOS. – Szabolcs Nov 12 '15 at 21:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.