First, I needed to find the file where the information is stored. The notes are kept in a single sqlite3 database file.
While my Linux box can mount the ipod as a filesystem, it seemed to be mounted to a subfolder on the ipod where I couldn't get access to other folders above. After googling for a half hour for a solution I gave up and plugged it into my Windows box instead.
In iTunes I made a backup of the ipod, right-clicking it in the list on the left and selecting "backup" from the context menu. You'll probably want to disable encryption if you are using it. Next I found the backup files here with Explorer:
C:\Documents and Settings\USERNAME ...\Application Data\Apple Computer\MobileSync\BackupYou will find several folders here, choose the one with the latest Date Modified set to a few minutes ago. Inside there will be hundreds of .mdddata files inside. There are a few ways to figure out which file is the one we are looking for. At first I poked around with the find command:
find "SQLite format 3" *.mddataThis was helpful, but then I realized I had entered a few notes recently. So I sorted the files in Explorer, again by Date Modified. I looked at the most recent files with Notepad++ (which will open them without issue, even though they have many nonprinting characters inside.)
On the third file, I found the "SQLite format 3" header, and after scrolling down the text of my Notes. Now we're getting somewhere. I copied off the file and renamed it to notes.db.
Here is a python script I found online purporting to export the data, but it didn't work. Maybe it is for a different version? This is a first generation ipod touch with iOS v3.x on it.
I then decided to copy the file back to the Linux box and investigate it there, as it is so easy to get sqlite installed. Installing sqlite and running the script could probably be done on Windows without too much trouble. To install:
sudo apt-get install sqlite3 sudo apt-get install python-pysqlite2After investigating the db file in sqlite I was able to fix and improve the script and have included it below. Save it as export_notes.py and give it your notes.db file as an argument.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
''' Extract notes from an iphone or ipod touch. ''' import sys, os import sqlite3 invalid_chars = r'<>:"/\|?*' html = u'''<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> %s </body></html> ''' outdir = 'out' def valid_fname(fname): return ''.join(c for c in fname if c not in invalid_chars) # make dir if not os.path.exists(outdir): os.makedirs(outdir) c = sqlite3.connect( sys.argv if len(sys.argv) > 1 else sys.exit('Filename param required.') ) titles = dict(c.execute('select rowid, title from Note order by rowid;')) bodies = dict(c.execute('select note_id, data from note_bodies order by rowid;')) for note_id, data in bodies.items(): title = titles.get(note_id, 'id_%s' % note_id) print 'exporting:', title fname = os.path.join(outdir, valid_fname('%s.html' % title)) with open(fname, 'wb') as outf: outf.write( (html % data).encode('utf-8') ) c.close()
Upon execution, it will create an out folder, which will contain an html file for each note. I never used formatting in any of my notes (not even sure how) but unfortunately they are stored as html. I would prefer plain text, but not going to bother to write a scraper. Hope this helps someone out there.