Hi. Welcome to MacScripter.
Unhelpfully, I don’t use Notes myself and don’t have Evernote. But looking at Notes’s scripting dictionary, it definitely doesn’t mention a ‘selection’. You could use a ‘choose from list’ dialog to choose the folder(s) from which to export. The script below is just an illustration of that. It assumes that the folders are all at the top level of Notes and have unique names.
One problem you may have to address with attachments is that a note can have more than one. Presumably these would all need to be saved somewhere and attached individually to the Evernote note. I’m afraid I can’t help with that.
tell application "Notes"
activate
set folderNames to name of folders
set chosenFolderNames to (choose from list folderNames with multiple selections allowed)
if (chosenFolderNames is false) then error number -128 -- Cancel button.
end tell
repeat with thisName in chosenFolderNames
tell application "Notes" to set theMessages to notes of folder thisName
repeat with thisMessage in theMessages
tell application "Notes"
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 myAttachments to the attachments of thisMessage
if (myAttachments is not {}) then
-- Save attachment(s), if any. (Where? Repeat loop needed?)
end if
end tell
(* tell application "Evernote"
set myNote to create note with text myTitle title myTitle notebook "Imported From Notes" tags ["imported_from_notes"]
set the HTML content of myNote to myText
append theNewNote attachment the_file -- Repeat loop needed?
set the creation date of myNote to myCreateDate
set the modification date of myNote to myModDate
end tell *)
end repeat
end repeat
Edit: The outer repeat now cycles through the correct list!