(This article is also available via the short link tomrei.ch/android-mms)
SMS/MMS has become my primary method of communication with most of my family and friends, and the ability to share pictures and video is an awesome feature. The data-hoarder in me, however, has always been disappointed with my inability to easily save off this media so I can easily access it later. Sure, it's possible in the Android Messages app to individually save off each picture/video, but that's a huge pain and basically impossible if you have a backlog of years worth of messages to go through
I've been using the app SMS Backup and Restore, available in the Google Play Store, for years. It allows me to backup all my messages, and when moving phones, transfer all existing messages over. A few years ago, I decided to poke at the XML backup file it produces and it was nice to see all my messages there, even if in a somewhat disorganized fashion. And, fortunately, MMS messages too.
Wanting to extract the images/videos, I threw together a PowerShell script to pull them out and organize them. It creates a directory for each contact, and places the content named by the date/time stamp that it was received. Initially I attempted to use PowerShell's XML parser to do the heavy lifting, but the sheer size of the file caused it to choke on all but the beefiest of machines, so I decided to take a more rudimentary approach using regular expressions. This produces a much faster result.
Running the script is pretty easy...
PS> .\SMS-Backup-And-Restore-Image-Extractor.ps1 -smsXmlFile sms-backup-file.xml
...and it will drop all the parsed contents in the same directory. There are options available to
change the output directory if necessary (see
Get-Help for more details).
You can find the script here and the full project on GitHub here. Parsing was working as of June 2019, the last time I did a backup. I've moved on to a different service for SMS/MMS, but I suspect I'll be back in Android Messages land before long, so I will update if needed.