├── LICENSE ├── README.md └── notes-export.scpt /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alex Chan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # notes-export 2 | 3 | ### Export HTML copies of your notes from Apple Notes 4 | 5 | I have tested this on the OS X El Capitan GM and a few of the developer seeds (I can't remember which ones); it probably doesn't work on older versions. 6 | 7 | To go in the other direction, see Steven Frank's [notes-import script](https://github.com/panicsteve/notes-import). 8 | 9 | -- 10 | -- notes-export.scpt 11 | -- Alex Chan 12 | -- 13 | -- Export all the notes from Notes.app into a folder as HTML text. 14 | -- A very basic backup script. 15 | -- 16 | -- Usage: 17 | -- * Open this file in Script Editor 18 | -- * Run 19 | -- * Select a folder to export files to 20 | -- 21 | -- Output: 22 | -- * A collection of (Latin-1 encoded) HTML files 23 | -- * A list of attachment names for each note. 24 | -- 25 | -- Known issues: 26 | -- * Only the names of attachments are exported, not the files 27 | -- themselves. (Look for the files in 28 | -- ~Library/Group Containers/group.com.apple.notes/Media). 29 | -- * Some attachment types (e.g. app links) show up as "Missing value" 30 | -- * Some formatting is lost. 31 | -- * A note with the same title as a previously exported note will be 32 | -- overwritten. 33 | -- * It will exported notes in the "Recently Deleted" folder which 34 | -- haven't been purged from disk yet. 35 | -- -------------------------------------------------------------------------------- /notes-export.scpt: -------------------------------------------------------------------------------- 1 | -- 2 | -- notes-export.scpt 3 | -- Alex Chan 4 | -- 5 | -- Export all the notes from Notes.app into a folder as HTML text. 6 | -- A very basic backup script. 7 | -- 8 | -- Usage: 9 | -- * Open this file in Script Editor 10 | -- * Run 11 | -- * Select a folder to export files to 12 | -- 13 | -- Output: 14 | -- * A collection of (Latin-1 encoded) HTML files 15 | -- * A list of attachment names for each note. 16 | -- 17 | -- Known issues: 18 | -- * Only the names of attachments are exported, not the files 19 | -- themselves. (Look for the files in 20 | -- ~Library/Group Containers/group.com.apple.notes/Media). 21 | -- * Some attachment types (e.g. app links) show up as "Missing value" 22 | -- * Some formatting is lost. 23 | -- * A note with the same title as a previously exported note will be 24 | -- overwritten. 25 | -- * It will exported notes in the "Recently Deleted" folder which 26 | -- haven't been purged from disk yet. 27 | -- 28 | 29 | set exportFolder to (choose folder) as string 30 | 31 | 32 | -- Find and Replace text. Yes, this really takes 11 lines. 33 | -- Taken from http://brucep.net/2007/replace-text/ 34 | on replaceText(find, replace, subject) 35 | set prevTIDs to text item delimiters of AppleScript 36 | set text item delimiters of AppleScript to find 37 | set subject to text items of subject 38 | 39 | set text item delimiters of AppleScript to replace 40 | set subject to "" & subject 41 | set text item delimiters of AppleScript to prevTIDs 42 | 43 | return subject 44 | end replaceText 45 | 46 | 47 | -- Get an HTML file to save the note in. We have to escape 48 | -- the colons or AppleScript gets upset. 49 | on noteNameToFilePath(noteName) 50 | global exportFolder 51 | return (exportFolder & replaceText(":", "_", noteName) & ".html") 52 | end noteNameToFilePath 53 | 54 | 55 | tell application "Notes" 56 | set attachmentLog to open for access (exportFolder & "_attachments.txt") with write permission 57 | repeat with theNote in notes 58 | 59 | -- Write the body of the note out to file as HTML 60 | set filepath to noteNameToFilePath(name of theNote as string) of me 61 | set noteFile to open for access filepath with write permission 62 | write (body of theNote as string) to noteFile 63 | close access noteFile 64 | 65 | -- Record a list of attachments for this file 66 | if (count of (attachments of theNote)) is greater than 0 then 67 | write ("\n" & name of theNote & ":\n\n") to attachmentLog 68 | end if 69 | 70 | repeat with theAttachment in attachments of theNote 71 | write ("* " & name of theAttachment & "\n") to attachmentLog 72 | end repeat 73 | 74 | end repeat 75 | 76 | close access attachmentLog 77 | end tell 78 | --------------------------------------------------------------------------------