Migrating Notes from Mark/Space Notebook to Apple Notes
I recently upgraded my iPhone 4s to an SE and lost the ability to run Mark/Space Fliq Notes on the SE. That's a pretty significant impact to me, as my whole life is organized by those notes, and being able to access them on both the iPhone (with Fliq Notes) and the MBP (with Mark/Space Notebook) has been a literal lifesaver. I'd delayed upgrading not only the phone, but the OS on the Macbook Pro as well, because Apple had eliminated the ability to sync locally after Mountain Lion. And up until El Capitan, notes were not encrypted when they were stored on Apple's iCloud servers, which was a game stopper for me. Thanks to Tom Cook's well placed concern for the security and privacy of user data, that is no longer an issue, but migrating out of the ancient Notebook application was. Others have had the same issue, but searching here didn't uncover anything helpful. I did find a solution at the MacScripter web site that relies on Applescript. However, it needed a tweak or two to get it to work in a predictable fashion, so I thought I'd post what I did here in hopes that it might help someone else. Here's how I went about the migration, more or less step by step.
For the record, the MBP is running MacOS 10.11.4 and the iPhone was on iOS 9.3.1.
1. Export the notes from Mark/Space Notebook on the MBP: My notes are organized in folders, so I exported each folder of notes to a folder on the MBP. I did that by selecting all the notes in a particular Notebook folder, then using the Export... function under the File Menu. At the bottom of that dialog box, I used the New Folder to create a Notebook Export folder on the Desktop, then within it a folder titled after the Notebook folder I was exporting. Once the new folder was selected in the file browser, I just clicked the "Choose a folder" button to execute the export. This creates a text file for each of the Notebook notes in the chosen folder. It is these files that the Applescript will import into the Apple Notes application. I repeated this for each of the Notebook folders.
2. Here's the link to the thread on MacScripter that had the Applescript:
http://macscripter.net/viewtopic.php?id=39166
I changed the script in two ways:
The call to tidy was causing conversion errors, and since the source files were simple ascii text and not utf-8, tidy wasn't needed. So I just deleted the following text from that line: & " | /usr/bin/tidy -ib -utf8"
Then I changed the script so it would automatically create a new folder in Apple Notes with the same name as the directory enclosing the exported Notebook files. Actually the new folder has the complete path to the directory as well as the directory itself, but it would have taken longer for me to figure out how to extract the directory name than just to edit the folder name in Notes, so I didn't bother fixing it.
Here's the final script:
-- this imports all the files in a folder into Notes.app in MacOSX 10.8 Mountain Lion
-- it converts files into a format compatible with Notes.app and creates a new note from that converted text
-- find lots of Notes scripts here: http://www.macosxautomation.com/applescript/notes/index.html
-- choose the folder with the notes that are being imported
set notesFolder to choose folder
-- find al the files in that folder
tell application "Finder"
set noteFiles to (files of entire contents of notesFolder) as alias list
end tell
-- get the name of the account that you want to add the notes to
set accountName to getNameOfTargetAccount()
-- get the name of the folder to add the notes to
-- set folderName to getNameOfTargetFolderOfAccount(accountName)
set folderName to notesFolder as text
-- make sure the folder exists in Notes
tell application "Notes"
tell accountaccountName
if not (existsfolderfolderName) then makenewfolderwith properties {name:folderName}
-- if not (exists folder notesFolder) then make new folder with properties {name:notesFolder}
end tell
end tell
repeat with noteFile in noteFiles
-- get the note name from the file name
set {noteName, ext} to getName_andExtension(noteFile)
-- get the file's text as html
if ext is "html" then
set noteText to readnoteFile
else
-- convert the file's contents into html code
-- set noteText to do shell script "/usr/bin/textutil -stdout -convert html " & quoted form of POSIX path of noteFile & " | /usr/bin/tidy -ib -utf8"
set noteText to do shell script "/usr/bin/textutil -stdout -convert html " & quoted form of POSIX path of noteFile
end if
-- add the note to the folder
tell application "Notes"
tell accountaccountName
tell folderfolderName
makenewnotewith properties {name:noteName, body:noteText}
end tell
end tell
end tell
end repeat
(****************** SUBROUTINES *****************)
-- this lets you choose which acount you want to target
-- if there's only 1 account then that account name is returned
on getNameOfTargetAccount()
tell application "Notes"
if (count of accounts) is greater than 1 then
set theseAccountNames to the name of every account
set thisAccountName to choose from list theseAccountNames with prompt "Add note to which account?"
if thisAccountName is false then error number -128
set thisAccountName to thisAccountName as text
else
set thisAccountName to the name of first account
end if
return thisAccountName
end tell
end getNameOfTargetAccount
-- this lets you choose which folder you want to target from an account
-- if there's only 1 folder then that folder name is returned
on getNameOfTargetFolderOfAccount(accountName)
set folderName to missing value
tell application "Notes"
tell accountaccountName
if (count of folders) is greater than 1 then
set theseFolderNames to the name of every folder
set folderName to choose from list theseFolderNames with prompt "Add note to which folder?"
if folderName is false then error number -128
set folderName to folderName as text
else
set folderName to the name of first folder
end if
end tell
end tell
return folderName
end getNameOfTargetFolderOfAccount
on getName_andExtension(f)
set f to f as text
set {name:nm, name extension:ex} to info for file f without size
if ex is missing value then
set ex to ""
else
set nm to text 1 thru ((count nm) - (count ex) - 1) of nm
end if
return {nm, ex}
end getName_andExtension
To use it, copy the above text, launch AppleScript Editor, and paste it into an empty editor window. Save the result with a name you can remember in a place you can find it, like NotesImport.scpt on the Desktop.
Click the Run button at the top of the edit window, and you'll be presented with a file browser window where you can navigate to one of the exported directories. Select the desired directory and click the Choose button. If you are displaying notes from both iCloud and On My Mac (check the "On My Mac" Account menu item under the Notes menu in Apple Notes to see local notes in Notes), you'll then be asked if you would like the notes imported to your Mac or to iCloud. Both work fine, and you can move notes from one location to another by simply dragging them, so you can always change your mind later. Pick one or the other and click the OK button to complete the import.
Back in Apple Notes, you should find a new folder with a pretty long name, the last bit of which should be the same as the directory that contained your exported Notebook notes. Click once on the folder name, then once more to edit the name and remove the extra characters.
If you've configured iCloud properly on both your Mac and iPhone, and the new notes were imported into the iCloud account, they should appear automatically on your iPhone. If not, check both devices under the iCloud System Preference/Setting to make sure Notes synchronization is enabled.
Apple Notes-OTHER, iOS 9.3.1, MacOS 10.11.4