Jump to content

Importing from Apple Mail.app's Notes


Recommended Posts

If you can get Mail.app to export your notes as separate files (either RTF or plain text), you can then import these into Evernote by dragging them on to our dock icon. I tried selecting several notes and either copying or Save As from Mail.app, and it seemed to always want to create a single block of text in a file rather than multiple files.

Link to comment

This is very easy in Ruby using appscript.

The main point is, the notes have to be dragged into a new mailbox. For whatever reason, the Notes "folder" doesn't exist where Mail's scripting is concerned. In this example, I made a new mailbox called "NoteMigrate" so it appeared under "On My Mac." The script will create a notebook called "ImportedMessages" if you don't have one already, and it will tag each note with "imported_note."

The first line of a given note is the 'subject.' All the lines of a note, including the first, are the content.


#!/usr/bin/ruby
require 'rubygems'
require 'appscript'
include Appscript

en = app("Evernote")
mail = app("Mail")

notes_folder = mail.mailboxes["NoteMigrate"]
messages = notes_folder.messages.get

messages.each do |m|
en.create_note(:title => m.subject.get,
:notebook => "ImportedNotes",
:with_text => m.content.get,
:tags => "imported_note")

end

I don't do much scripting with Applescript directly because I got more fluent with Ruby using rb-appscript much more quickly. The logic is so straightforward I'm sure an adept Applescripter will be able to translate it. If nobody shows how in a day or two, I'll do it.

  • Like 1
  • Thanks 1
Link to comment

Well, it was pretty easy in AppleScript, too, since I had some scrap code from a while back. Same deal as before: Drag all the notes into a new mailbox called "NoteMigrate."

No error checking or anything. Worked for me:


tell application "Mail"
set theMessages to every message of the mailbox "NoteMigrate"
repeat with thisMessage in theMessages
set myTitle to the subject of thisMessage
set myText to the content of thisMessage
tell application "Evernote"
create note with text myText title myTitle notebook "Imported Notes" tags "imported_note"
end tell
end repeat
end tell

  • Like 2
Link to comment
  • 1 year later...

Works great, but Is the created or last modified date available to add to this import code? That's pretty important sometimes, and the fact that Mail.app notes doesn't seem to track date created is one of the problems that motivated my search for Evernote.

Link to comment

You just need to grab the "date sent" attribute when you look at the original note, then add it as the "created" property to the newly created Evernote item.

The AppleScript version:

tell application "Mail"
set theMessages to every message of the mailbox "NoteMigrate"
repeat with thisMessage in theMessages
set myTitle to the subject of thisMessage
set myText to the content of thisMessage
set myCreateDate to the date sent of thisMessage
tell application "Evernote"
create note with text myText title myTitle notebook "Imported Notes" tags "imported_note" created myCreateDate
end tell
end repeat
end tell

The Ruby/rb-appscript version:

#!/usr/bin/ruby
require 'rubygems'
require 'appscript'
include Appscript

en = app("Evernote")
mail = app("Mail")

notes_folder = mail.mailboxes["NoteMigrate"]
messages = notes_folder.messages.get

messages.each do |m|
en.create_note(:title => m.subject.get,
:notebook => "ImportedNotes",
:with_text => m.content.get,
:tags => "imported_note",
:created => m.date_sent.get)

end

  • Like 1
Link to comment
  • 1 year later...
  • 2 months later...
  • 1 year later...

Apple Script version: This worked great, but as a first time user of apple script, I had to figure out a few things.

1. Open up the application "Apple Script Editor."

2. Paste in the text from the post above.

3. Open Mail application. Control-click on "inbox" and make a "New Mailbox..." and name it "NoteMigrate."

4. Select all your notes and move them into the new folder "NoteMigrate."

5. Open Evernote app on your Mac. (not sure this is necessary, but I did it)

6. Go back to Apple Script Editor. Hit Compile. (not sure compile is necessary, but I did it)

7. Click the icon "Run."

8. Wait.

9. Go back to Evernote, and see the result.

10. Dance. (not sure this is necessary, but I did it)

  • Like 2
Link to comment
  • 3 months later...

This method indeed rocks, but there's still one more detail before you get the full A+...

The capture of creation was a nice improvement, but many users also like to sort the notes based on date updated, from most recent to least recent, right?

The output from your script currently creates a rather awkward situation, since it actually reverses this order due to the fact that the "updated" date defined in Evernote for the newly imported notes is set by the order in which they are imported, and it seems that the script by default imports them starting from the most recently updated to least recent, as defined in the Mac's Note database. Once they land in evernote, they all have the correct original creation dates (lovely!), but they all have today's import date and time for their "updated" values (so they all differ by about 1 seoncd or so, as the script was walking through the list).

Tried a quick "dumb fix" of reversing the sort order in Mac Mail prior to import but this doesn't help, since it is just a viewing option: the script apparently follows the order set by the last modified date of these notes.

So I see two possible fixes, neither of which I can implment myself, as I don't know enough about scripting, so I'm greatly appreciate if one of you could help here:

-the smart fix: figure out how to capture the "last updated" values from the Mac database, and use them to reset the corresponding "updated" values in Evernote after the import is complete.

-the acceptable work-around: if resetting the "updated" values correctly is not possible, then you could maybe get the script to at least least reestablish the correct "updated" order by altering this order either before or after the import, by getting either Mac Mail or Evernote to go into each of the notes in the reverse order and adding a benign edit (e.g. an extra space or punctuation character at the very end of the note text field). This would result in the correct "udpated-based sorting", at the modest price of losing the actual last update dates from before the import process.

Make sense?

If so, I'd greatly appreciate if pdxmph (or anyone else with the right scripting know-how) would be wiling to update the script accordingly... Which would then get A+ rock status in my book as well... ;-)

Cheers!

Link to comment
  • 2 months later...

To make the AppleScript version add in reverse order:

 

tell application "Mail"	set theOMessages to every message of the mailbox "NotesExport"	set theMessages to reverse of theOMessages	repeat with thisMessage in theMessages		set myTitle to the subject of thisMessage		set myText to the content of thisMessage		set myCreateDate to the date sent of thisMessage		tell application "Evernote"			create note with text myText title myTitle notebook "Imported Notes" tags "imported_note" created myCreateDate		end tell	end repeatend tell
Link to comment
  • 6 months later...

When I run these scripts, after importing five notes, Evernote returns

 

 

Internal Error.

An internal database error has occurred that prevents Evernote from functioning properly.  If the problem persists, please contact Evernote Support.

 

 

Link to comment

Here's a fix I kludged up. I'd much rather have it pick, say, the first four words, but when I tried that it came out allruntogether, and I didn't see an easy way to remedy that.

 

 

tell application "Mail"

set theOMessages to every message of the mailbox "NotesExport"

set theMessages to reverse of theOMessages

repeat with thisMessage in theMessages

set myTitle to the subject of thisMessage

set myCount to count characters of myTitle

if myCount is greater than 20 then

set theTitle to characters 1 through 20 of myTitle as string

else

set theTitle to myTitle

end if

set myText to the content of thisMessage

set myCreateDate to the date sent of thisMessage

tell application "Evernote"

create note with text myText title theTitle notebook "Imported Notes" tags "iOS" created myCreateDate

end tell

end repeat

end tell

Link to comment
  • 4 weeks later...

Modified this script to work with Mavericks Notes, which is no longer in the mail app.


Added the original creation and modification dates


Added multiple tags - replace with your own


 


Did not add the long note name fix (I needed to preserve my note names)


 


tell application "Notes"


set theMessages to every note


repeat with thisMessage in theMessages


set myTitle to the name of thisMessage


set myText to the body of thisMessage


set myCreateDate to the creation date of thisMessage


set myModDate to the modification date of thisMessage


tell application "Evernote"


set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]


set the HTML content of myNote to myText


set the creation date of myNote to myCreateDate


set the modification date of myNote to myCreateDate


end tell


end repeat


end tell


 


Enjoy


  • Like 5
Link to comment
  • 3 months later...
  • 2 months later...

I currently have over 500 notes on my Apple desktop computer in the app notes.

 

I want to move them into Evernote, as separate notes.

 

Having looked at the steps above, 

 

1. I can not get the Notes into my Mailbox, unless I do each one manually.

 

I think it may be the Maverick iOS edition as there is no option for showing notes in Mail.

 

 

Please could someone advise me on how I can get these Apple Notes on to Mail, then Mail to Evernote.

Thanks

Link to comment

I currently have over 500 notes on my Apple desktop computer in the app notes.

 

I want to move them into Evernote, as separate notes.

 

Having looked at the steps above, 

 

1. I can not get the Notes into my Mailbox, unless I do each one manually.

 

I think it may be the Maverick iOS edition as there is no option for showing notes in Mail.

 

 

Please could someone advise me on how I can get these Apple Notes on to Mail, then Mail to Evernote.

Thanks

You should be able to use d.b.walker's applescript posted in this very thread (two posts above yours). https://discussion.evernote.com/topic/4046-importing-from-apple-mailapps-notes/?p=236445

Link to comment
  • 1 month later...

Found that not all of my 1500+ notes from Apple's Notes.app had delineated titles. Since the "title" of a note is generally the first line, I was getting errors from Evernote when it was trying to create notes with a title larger than 255 characters. I suppose you could truncate the title to only take the first 255 characters of the title, but I found that setting title to the creation date as a string was more clean. Hope this helps anyone running into the same problem!

tell application "Notes"	set theMessages to every note	repeat with thisMessage in theMessages		set myTitle to the creation date of thisMessage as string		set myText to the body of thisMessage		set myCreateDate to the creation date of thisMessage		set myModDate to the modification date of thisMessage		tell application "Evernote"			set myNote to create note with text myText title myTitle notebook "Imported" tags ["imported_from_Apple_notes"]			set the HTML content of myNote to myText			set the creation date of myNote to myCreateDate			set the modification date of myNote to myCreateDate		end tell	end repeatend tell
  • Like 1
Link to comment
  • 1 month later...

Thanks d.b.walker! It worked perfectly!

 

*Dale*

 

 

Modified this script to work with Mavericks Notes, which is no longer in the mail app.

Added the original creation and modification dates

Added multiple tags - replace with your own

 

Did not add the long note name fix (I needed to preserve my note names)

 

tell application "Notes"

set theMessages to every note

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

 

Enjoy

 

  • Like 1
Link to comment
  • 1 month later...
  • 2 weeks later...

I'm using the script but it's giving me an ["... Connection is invalid." number -609] error. I end up with about 2/3rds of my 250 Notes imported. I can't see any pattern of which Notes are imported and which aren't.

 

Any suggestions?

 

 

Thanks d.b.walker! It worked perfectly!

 

*Dale*

 

 

Modified this script to work with Mavericks Notes, which is no longer in the mail app.

Added the original creation and modification dates

Added multiple tags - replace with your own

 

Did not add the long note name fix (I needed to preserve my note names)

 

tell application "Notes"

set theMessages to every note

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

 

Enjoy

 

 

Link to comment
  • 2 weeks later...
  • 1 month later...

In case you have Notes from multiple accounts, like I do (some in iCloud, some on Exchange, etc.) you can add this line to pull the account name of the note:

set myAccount to the name of the container of the container of thisMessage

and then add this line in there to put it into a corresponding Evernote notebook:

​set myNote to create note with text myTitle title myTitle notebook myAccount tags ["Whatever", "Tags", "you", "want"]

 

Modified this script to work with Mavericks Notes, which is no longer in the mail app.

Added the original creation and modification dates

Added multiple tags - replace with your own

 

Did not add the long note name fix (I needed to preserve my note names)

 

tell application "Notes"

set theMessages to every note

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

 

Enjoy

 

  • Like 1
Link to comment

Hi! I am also interested in merging my Apple Notes to Evernote. Could someone explain exactly how to run this script in a step-by-step process for people who know nothing about coding, etc? I assume you cut and paste this, but to where? Then you run, and then what? You just open Evernote and everything is there? Could someone outline the exact process? I'm on Yosemite. I don't have any Notes name more than 255 characters. Thanks!

 

kevin

Link to comment

I currently have over 500 notes on my Apple desktop computer in the app notes.

 

I want to move them into Evernote, as separate notes.

 

Having looked at the steps above, 

 

1. I can not get the Notes into my Mailbox, unless I do each one manually.

 

I think it may be the Maverick iOS edition as there is no option for showing notes in Mail.

 

 

Please could someone advise me on how I can get these Apple Notes on to Mail, then Mail to Evernote.

Thanks

 

 

I compiled and created the Application for the beginners

 

http://artpromac.com/ExportNotetoEvernotebyArtProMac.zip

Link to comment
  • 1 month later...

i can see this script importing my 550 notes to evernote... i trusted the .zip file listed on the link of the last post before me and its just beautifull!!! ( i didnt know where to start with the script)... i agree that the dates are an issue but i finally have acces to my notes so i dont care about the date!!! 

 

thanks to all of you!!! you really made my switch from ios to android finally possible! 

 

SgtYzi

Link to comment

I am running Yosemite (Mac OS X 10.10.1 and consequently Apple Notes 3.1 and with the script below I receive the error: "Syntax Error Notes got an error: AppleEvent handler failed." at line two with "every note" highlighted.

Can anyone help?

 

tell application "Notes"

set theMessages to every note

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Yosemite", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

Link to comment
  • Level 5*

I am running Yosemite (Mac OS X 10.10.1 and consequently Apple Notes 3.1 and with the script below I receive the error: "Syntax Error Notes got an error: AppleEvent handler failed." at line two with "every note" highlighted.

Can anyone help?

 

tell application "Notes"

set theMessages to every note

. . .

 

You might try a Google on "applescript select all notes" since the issue seems to be in how you are trying to select all Notes.

Link to comment

Hi JMichael,

I cannot seem to find any apple script command for 'select all' in notes. But is that even possible? Surely there must be such a command. I can certainly select all notes manually in the notes app, so why would this scripting feature be absent?

Thanks ever so much for your help.

A.

Link to comment
  • Level 5

I cannot seem to find any apple script command for 'select all' in notes. But is that even possible? Surely there must be such a command. I can certainly select all notes manually in the notes app, so why would this scripting feature be absent?

 

You could try using keyboard shortcuts. Something like this maybe:

 

tell application "Evernote"	activate -- bring the Evernote client forward	delay 1 -- wait to make sure the client has fully activated	tell application "System Events"		keystroke "|" using command down -- Cmd-| to go to the note list		keystroke "a" using command down -- Cmd-A to select all	end tellend tell
Link to comment
  • Level 5

 

I cannot seem to find any apple script command for 'select all' in notes. But is that even possible? Surely there must be such a command. I can certainly select all notes manually in the notes app, so why would this scripting feature be absent?

 

You could try using keyboard shortcuts. Something like this maybe:

 

tell application "Evernote"	activate -- bring the Evernote client forward	delay 1 -- wait to make sure the client has fully activated	tell application "System Events"		keystroke "|" using command down -- Cmd-| to go to the note list		keystroke "a" using command down -- Cmd-A to select all	end tellend tell

I now see you were talking about the Notes app. A similar approach should work there too.

Link to comment

Sorry I'm such an applescript novice I've no idea how to include your suggestion. I've typed the following script out (and also tried to tweak it), but it gives me the following error: Expected end of line, etc. but found end of script.

 

tell application "Notes"

activate -- bring the Notes client forward

delay 1 -- wait to make sure the client has fully activated

tell application "System Events"

keystroke "|" using command down -- Cmd-| to go to the note list

keystroke "a" using command down -- Cmd-A to select all

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Yosemite", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

Link to comment
  • Level 5

Try this:

tell application "Notes"	set theMessages to every note	repeat with thisMessage in theMessages		set myTitle to the name of thisMessage		set myText to the body of thisMessage		set myCreateDate to the creation date of thisMessage		set myModDate to the modification date of thisMessage		tell application "Evernote"			set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Yosemite", "Another_Example_Tag"]			set the HTML content of myNote to myText			set the creation date of myNote to myCreateDate			set the modification date of myNote to myCreateDate		end tell	end repeatend tell
  • Like 1
Link to comment
  • Level 5*

@Adjusting:  I can see that you are an accomplished AppleScript coder.  Could you please help us get the AppleScript issues with EN Mac 6.0.5 fixed?  Many of use routinely rely on AppleScript in our Evernote workflows.

 

Thanks.

Link to comment
  • Level 5

@Adjusting:  I can see that you are an accomplished AppleScript coder.  Could you please help us get the AppleScript issues with EN Mac 6.0.5 fixed?  Many of use routinely rely on AppleScript in our Evernote workflows.

 

I’m good at debugging and modifying other people’s scripts, but I don’t know if I could write one from scratch.

 

The issue where find notes did not work with the 'notebook:' syntax should be fixed in 6.0.6 beta 2

Which other issues are affecting your workflows?

Link to comment
  • Level 5

Thank you Adjusting, but I don't see how your script differs from the one I initially tried (see my post dated 18 Jan 10:30AM).

Apologies if it is different.

No, you’re right. There doesn’t seem to be any difference. I was just trying to fix the problems with your latest script (using keyboard shortcuts that don’t exist, using theMessages before setting it, mismatched tell and end...) and didn’t reread the whole thread.

What were you trying to accomplish with your latest script that your original didn’t do?

Link to comment

Hi Adjusting,

What I'm trying to do is the titler of this discussion.

"Importing from Apple Mail.app's Notes"

Except that - as you probably realise - Yosemite has its own stand alone Notes App, meaning notes in Yosemite are no longer stored in the Apple Mail App.
Hope that helps.
Many thanks
Link to comment
  • Level 5

What I'm trying to do is the titler of this discussion.

"Importing from Apple Mail.app's Notes"

Except that - as you probably realise - Yosemite has its own stand alone Notes App, meaning notes in Yosemite are no longer stored in the Apple Mail App.

 

Right, but your original script already did that. I’m just trying to figure out what the goal of your changes was.

Link to comment
  • 3 weeks later...
  • 1 month later...

Excellent!  Worked perfectly. Thanks for posting this, Calion.

Here's a fix I kludged up. I'd much rather have it pick, say, the first four words, but when I tried that it came out allruntogether, and I didn't see an easy way to remedy that.

 

 

tell application "Mail"

set theOMessages to every message of the mailbox "NotesExport"

set theMessages to reverse of theOMessages

repeat with thisMessage in theMessages

set myTitle to the subject of thisMessage

set myCount to count characters of myTitle

if myCount is greater than 20 then

set theTitle to characters 1 through 20 of myTitle as string

else

set theTitle to myTitle

end if

set myText to the content of thisMessage

set myCreateDate to the date sent of thisMessage

tell application "Evernote"

create note with text myText title theTitle notebook "Imported Notes" tags "iOS" created myCreateDate

end tell

end repeat

end tell

Link to comment

This script will import all your Notes and create folders for each Account. For instance, if you have iCloud and a Gmail account, it will create "Imported iCloud" and "Imported Gmail" folders to store respective notes. It also sets mod date to the correct field. Thanks everyone for creating the base for this.

tell application "Notes"	set theNotes to every note	repeat with thisNote in theNotes		set myTitle to the name of thisNote		set myText to the body of thisNote		set myCreateDate to the creation date of thisNote		set myModDate to the modification date of thisNote		set myFolder to the container of thisNote		set myAccount to the container of myFolder		set myAccountName to the name of myAccount		set myAccountName to "Imported " & myAccountName		set myAccountName to myAccountName as string		tell application "Evernote"			set myNote to create note with text myTitle title myTitle notebook myAccountName			set the HTML content of myNote to myText			set the creation date of myNote to myCreateDate			set the modification date of myNote to myModDate		end tell	end repeatend tell
Link to comment
  • 2 weeks later...

Oh, My, Goodness! I can't believe that I just figured out how to do this!  Thank you SOOOO much for putting the notes here.  I have spent at least 1.5 hours trying to figure out something that "should" be simple - just download about 30 notes from my MacBook Notes to Evernote.  I "ran the script" that you suggested, and I am not sure what it really did, but now I see all these notes in Evernote.  Now, if my computer starts smoking, and little bugs start running out, I will know that it didn't work as well as I think, but thanks so much!  I feel so proud of myself, because I think I just "programmed" my computer, or something like that!!

Thanks again, Evernote geeks!

 

 

Link to comment
  • 5 weeks later...

 

Modified this script to work with Mavericks Notes, which is no longer in the mail app.

Added the original creation and modification dates

Added multiple tags - replace with your own

 

Did not add the long note name fix (I needed to preserve my note names)

 

tell application "Notes"

set theMessages to every note

repeat with thisMessage in theMessages

set myTitle to the name of thisMessage

set myText to the body of thisMessage

set myCreateDate to the creation date of thisMessage

set myModDate to the modification date of thisMessage

tell application "Evernote"

set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]

set the HTML content of myNote to myText

set the creation date of myNote to myCreateDate

set the modification date of myNote to myCreateDate

end tell

end repeat

end tell

 

Enjoy

 

How do I do this in Mavericks? Run in Apple Script Editor? Does Evernote need to be open?

Link to comment
  • 1 month later...

Nice work everyone - many thanks.

Has anyone figured how to include embedded images from your notes in Notes.app to the new Evernote note?

Thanks for the work of all.

Any news of that issue? I can not figure out how to export the body (text) + attachments (images) of Notes.app to Evernote.

 

Best

Link to comment
  • 2 weeks later...
  • 4 months later...

Worked like a charm, for all of my different accounts in the notes app ( local, gmail, icloud)

Cheers to you, sir!

 

 

This script will import all your Notes and create folders for each Account. For instance, if you have iCloud and a Gmail account, it will create "Imported iCloud" and "Imported Gmail" folders to store respective notes. It also sets mod date to the correct field. Thanks everyone for creating the base for this.

tell application "Notes"	set theNotes to every note	repeat with thisNote in theNotes		set myTitle to the name of thisNote		set myText to the body of thisNote		set myCreateDate to the creation date of thisNote		set myModDate to the modification date of thisNote		set myFolder to the container of thisNote		set myAccount to the container of myFolder		set myAccountName to the name of myAccount		set myAccountName to "Imported " & myAccountName		set myAccountName to myAccountName as string		tell application "Evernote"			set myNote to create note with text myTitle title myTitle notebook myAccountName			set the HTML content of myNote to myText			set the creation date of myNote to myCreateDate			set the modification date of myNote to myModDate		end tell	end repeatend tell
Link to comment
  • 1 month later...
  • 3 months later...

The script in this thread was helpful, but some of the modification dates for my notes were not right after I imported them. I think there is a bug in the script. The line that says 

set the modification date of myNote to myCreateDate

should say 

set the modification date of myNote to myModDate

instead.

Link to comment
  • Level 5*
On 3/24/2016 at 11:24 PM, Elias Zamaria said:

 I think there is a bug in the script.

Good catch!  Thanks for reporting.

@d.b.walker, if you are still around, could you please update your post/script to fix this bug so others do not encounter it.

Since that script is the one and only post of @d.b.walker, I suspect he may not be active in the forum.

So, I'm posting his code, with the bug fix identified by @Elias Zamaria, to make it easy for others to find in the future.
From the original script by @d.b.walker, with bug fix:

tell application "Notes"
  set theMessages to every note
  
  repeat with thisMessage in theMessages
    set myTitle to the name of thisMessage
    set myText to the body of thisMessage
    set myCreateDate to the creation date of thisMessage
    set myModDate to the modification date of thisMessage
    
    tell application "Evernote"
      set myNote to create note with text myTitle title myTitle notebook "Imported Notes" tags ["imported_from_notes", "Mavericks", "Another_Example_Tag"]
      set the HTML content of myNote to myText
      set the creation date of myNote to myCreateDate
      set the modification date of myNote to myModDate -- BUG FIX
    end tell
    
  end repeat
end tell

NOTE:  I have not tested this code, so I can NOT vouch for it.  Use at your own risk.

Link to comment
  • 1 year later...

I've made a minor adjustment to this code, it preserves folders and account by making a new notebook for each folder (within an account) and tags the account the note is associated with. This can be easily switched if you prefer your notebooks to be based on accounts and tagged with the folders. 
 

tell application "Notes"
	set theMessages to every note
	repeat with thisMessage in theMessages
		set myTitle to the name of thisMessage
		set myText to the body of thisMessage
		set myCreateDate to the creation date of thisMessage
		set myModDate to the modification date of thisMessage
		set thisItem to thisMessage
		set myAccount to null
		set myFolder to null
		repeat
			set thisContainer to the container of thisItem
			if (the class of thisContainer) is folder then
				set myFolder to name of thisContainer
			else if (the class of thisContainer) is account then
				set myAccount to name of thisContainer
			end if
			if myFolder is not null and myAccount is not null then
				exit repeat
			else
				set thisItem to thisContainer
			end if
		end repeat
		tell application "Evernote"
			set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount
			set the HTML content of myNote to myText
			set the creation date of myNote to myCreateDate
			set the modification date of myNote to myCreateDate
		end tell
	end repeat
end tell

 

 

if you want to make the notebook names from accounts and the tags from folders (opposite of what I have), you would change "set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount" to "set myNote to create note with text myTitle title myTitle notebook myAccount tags myFolder".

  • Like 3
Link to comment
  • 1 month later...

Thank you Matthew. For some reason, none of the HTML or attachments in my Notes get exported to Evernote with your script or the original script, just the plain text, title, and dates. A lot of my notes have HTML links to the original web pages I created them from. How can i migrate that?

Link to comment
  • 1 month later...
On 9/1/2017 at 8:20 PM, Matthew Sangster said:

I've made a minor adjustment to this code, it preserves folders and account by making a new notebook for each folder (within an account) and tags the account the note is associated with. This can be easily switched if you prefer your notebooks to be based on accounts and tagged with the folders. 
 


tell application "Notes"
	set theMessages to every note
	repeat with thisMessage in theMessages
		set myTitle to the name of thisMessage
		set myText to the body of thisMessage
		set myCreateDate to the creation date of thisMessage
		set myModDate to the modification date of thisMessage
		set thisItem to thisMessage
		set myAccount to null
		set myFolder to null
		repeat
			set thisContainer to the container of thisItem
			if (the class of thisContainer) is folder then
				set myFolder to name of thisContainer
			else if (the class of thisContainer) is account then
				set myAccount to name of thisContainer
			end if
			if myFolder is not null and myAccount is not null then
				exit repeat
			else
				set thisItem to thisContainer
			end if
		end repeat
		tell application "Evernote"
			set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount
			set the HTML content of myNote to myText
			set the creation date of myNote to myCreateDate
			set the modification date of myNote to myCreateDate
		end tell
	end repeat
end tell

 

 

if you want to make the notebook names from accounts and the tags from folders (opposite of what I have), you would change "set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount" to "set myNote to create note with text myTitle title myTitle notebook myAccount tags myFolder".

works amazing 

can you make all of the attached pictures and pdf inside the notes to transfer to?
this will be wonderful  

Link to comment
  • 3 weeks later...
  • 9 months later...

Has anyone had luck with this script in High Sierra? I was able to run this before on an older version of Mac OS, but now I am seeing errors: "Evernote got an error: The operation couldn't be completed. (Evernote XML Error error 4.)"

I posted my question here, but haven't gotten help there either.

 

Link to comment
  • Level 5*
25 minutes ago, lw116 said:

Has anyone had luck with this script in High Sierra? I was able to run this before on an older version of Mac OS, but now I am seeing errors: "Evernote got an error: The operation couldn't be completed. (Evernote XML Error error 4.)"

Could you post the actual script you're trying to run1488427872_ScreenShot2018-11-02at12_26_44.thumb.png.00c83b0d94c208990e8f55401ee376e9.png
I ran this script without any errors.

However, this only copies the text.  
It does not copy any attachments.
 

Link to comment
  • 1 month later...

Hello everyone,

The above code works brilliantly to transfer all my notes (thanks a lot!!).

However, I can't manage to transfer the titles.

Anything more than 70-80 characters gets truncated. Hence, the first paragraph from IoS notes is being lost.

i.e 
First paragraph In IOS - "Volatility spread, maturity price matrix. They are using pd matrix for maximum 3-4 dimensions. For anything bigger than that Monte-Carlo simulation is used. "

Title in Evernote - "Volatility spread, maturity price matrix. They are using pd matrix…"

The second part of the above sentence does not appear anywhere in Evernote.

is it possible to transfer the ios note title into the body of the evernote note and rename the note by the date created?

Many thanks in advance.
 

  • Like 1
Link to comment
  • 3 weeks later...
On 9/1/2017 at 10:20 AM, Matthew Sangster said:

I've made a minor adjustment to this code, it preserves folders and account by making a new notebook for each folder (within an account) and tags the account the note is associated with. This can be easily switched if you prefer your notebooks to be based on accounts and tagged with the folders. 
 


tell application "Notes"
	set theMessages to every note
	repeat with thisMessage in theMessages
		set myTitle to the name of thisMessage
		set myText to the body of thisMessage
		set myCreateDate to the creation date of thisMessage
		set myModDate to the modification date of thisMessage
		set thisItem to thisMessage
		set myAccount to null
		set myFolder to null
		repeat
			set thisContainer to the container of thisItem
			if (the class of thisContainer) is folder then
				set myFolder to name of thisContainer
			else if (the class of thisContainer) is account then
				set myAccount to name of thisContainer
			end if
			if myFolder is not null and myAccount is not null then
				exit repeat
			else
				set thisItem to thisContainer
			end if
		end repeat
		tell application "Evernote"
			set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount
			set the HTML content of myNote to myText
			set the creation date of myNote to myCreateDate
			set the modification date of myNote to myCreateDate
		end tell
	end repeat
end tell

 

 

if you want to make the notebook names from accounts and the tags from folders (opposite of what I have), you would change "set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount" to "set myNote to create note with text myTitle title myTitle notebook myAccount tags myFolder".

It's the end of 2018 and this code still works to transfer Notes into Evernote. It ends with an error but a hand-audit revealed all notes made it into Evernote. This solution should be elevated within Evernote Support documents. Took a *ton* of time searching Google before tripping across this. If you need to export Apple Notes into Evernote... this is by far the fastest & easiest way to do it.

  • Like 1
Link to comment
  • 4 months later...

Hello.  This thread is very informative. Thank you.  I was able to transfer my notes to evernote.  However, my titles run longer than the character limit and are truncated by Apple notes during export.  My notes were not written with titles in mind and I did not realize the first line would be set to the title.  I tried concatenating the title to the body, but the title is truncated when it is set to the myTitle variable.  Is there a good way to preserve the full apple notes title?  Or does this require modifying every apple note with a new title to push the first line down into the body. 

Link to comment
  • Level 5*
On 5/28/2019 at 4:17 PM, dejalu said:

My notes were not written with titles in mind and I did not realize the first line would be set to the title.  I tried concatenating the title to the body, but the title is truncated when it is set to the myTitle variable.  Is there a good way to preserve the full apple notes title? 

As you say, Evernote Mac has a limit on the Note Title length, so you will either have to revise the text for the title, or let it be truncated.

I'm not clear on what action you want to perform at this time. 

  1. Do you want to modify the Evernote Notes that you imported from Apple Notes? 
  2. OR, do you want to re-import the Apple Notes and handle the Note Title differently?
  3. How many Notes need to be revised?
  4. What script did you use to import the Apple Notes?

Once we clearly understand what you want to do at this point, most likely there is a simple AppleScript solution.

Link to comment
  • Level 5*
On 5/28/2019 at 2:17 PM, dejalu said:

I was able to transfer my notes to evernote.  However, my titles run longer than the character limit and are truncated by Apple notes during export.  My notes were not written with titles in mind and I did not realize the first line would be set to the title.

We're not clear on which script you used, can you post it?

I'm thinking Apple Note titles would be comparable with Evernote titles, and for the most part the notes would be equivalent.   Can you provide specific examples (screenshots)

You have control with the script, and should be able to make adjustments as required.

Link to comment
  • 1 month later...

I was sent here by DoraOutLoud: https://medium.com/doraoutloud/migrating-your-apple-notes-to-evernote-12114418ba00

It's July 14, 2019, and the following code worked for me.

Thank you all.

On 12/31/2018 at 2:30 PM, Greendays Group said:

tell application "Notes" set theMessages to every note repeat with thisMessage in theMessages set myTitle to the name of thisMessage set myText to the body of thisMessage set myCreateDate to the creation date of thisMessage set myModDate to the modification date of thisMessage set thisItem to thisMessage set myAccount to null set myFolder to null repeat set thisContainer to the container of thisItem if (the class of thisContainer) is folder then set myFolder to name of thisContainer else if (the class of thisContainer) is account then set myAccount to name of thisContainer end if if myFolder is not null and myAccount is not null then exit repeat else set thisItem to thisContainer end if end repeat tell application "Evernote" set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount set the HTML content of myNote to myText set the creation date of myNote to myCreateDate set the modification date of myNote to myCreateDate end tell end repeat end tell

 

Link to comment
  • 2 months later...

Hello, I have few issues with the Import script on Mac. First, it doesn't import my attachments. But the most serious issue is that RTL (right-to-left) aligned notes I have on my Notes app are imported to Evernote aligned LTR.. If someone can help or have any idea I will appreciate it. Thanks! Roy

Link to comment
  • 3 months later...

I tried the following script in Catalina and thought it worked since the note count was the same in both apps. However, it duplicates some of the notes to hit that number. I've tried adding single folders and multiple folders with same results. In the single folder selection, it takes the last notes I've modified in Notes and imports regardless of whether they existed in the folder I selected for import. Truthfully, why doesn't Evernote create a support article with a solution rather than having people discuss this for over 10 years (literally). Any feedback to why it won't work? Thank you.

tell application "Notes"
	set theMessages to every note
	repeat with thisMessage in theMessages
		set myTitle to the name of thisMessage
		set myText to the body of thisMessage
		set myCreateDate to the creation date of thisMessage
		set myModDate to the modification date of thisMessage
		set thisItem to thisMessage
		set myAccount to null
		set myFolder to null
		repeat
			set thisContainer to the container of thisItem
			if (the class of thisContainer) is folder then
				set myFolder to name of thisContainer
			else if (the class of thisContainer) is account then
				set myAccount to name of thisContainer
			end if
			if myFolder is not null and myAccount is not null then
				exit repeat
			else
				set thisItem to thisContainer
			end if
		end repeat
		tell application "Evernote"
			set myNote to create note with text myTitle title myTitle notebook myFolder tags myAccount
			set the HTML content of myNote to myText
			set the creation date of myNote to myCreateDate
			set the modification date of myNote to myCreateDate
		end tell
	end repeat
end tell

 

Link to comment
  • 2 weeks later...

Any progress on this? I cannot believe that there is no easy way to migrate Apple Notes to Evernote?!?

I tried the script approaches above but I get errors like: error "„Notes“ hat einen Fehler erhalten: show id \"x-coredata://137C8659-8033-4414-B83B-B2202069CDB3/ICNote/p453\" kann nicht in Typ specifier umgewandelt werden." number -1700 from show id "x-coredata://137C8659-8033-4414-B83B-B2202069CDB3/ICNote/p453" to specifier

 

Link to comment
  • 11 months later...
  • 2 months later...

Arrived here via a blog post offering a solution to the migrate from Apple Notes to Evernote issue
(https://medium.com/doraoutloud/migrating-your-apple-notes-to-evernote-12114418ba00)

Tried the code listed on that post - which appears the same as the latest iteration of codes in this thread - but received the following error:

"Syntax Error
Expected expression, property or key form, etc. but found unknown token."

My OS: Catalina Version 10.15.7 with Notes Version 4.7 (1111.23)

I'm completely new to using Apple Script so am not yet comfortable tinkering with it & am hoping someone else here can help make the code run as intended on this newer OS! 🙏

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...