Так случилось, что появился у меня Evernote Premium, ввиду чего захотелось перенести накопленные за пару лет работы заметки из Apple Notes туда. Нашелся замечательный applescript-файл, позволяющий сделать это быстро и вкусно. Спасибо перечисленным в заголовке авторам и вообще всем участникам треда.
(*====================================================[EN] Import Apple Notes into Evernote====================================================DATE: 2013-10-24AUTHOR: d.b.walkerREVISED BY: JMichaelTX on 2016-03-28 to make BUG fix.REF:• Importing from Apple Mail.app's Notes - Mac Help - Evernote User Forum• https://discussion.evernote.com/topic/4046-importing-from-apple-mailapps-notes/?do=findComment&comment=236445Posted 24 Oct 2013Modified this script to work with Mavericks Notes, which is no longer in the mail app.Added the original creation and modification datesAdded multiple tags - replace with your ownDid not add the long note name fix (I needed to preserve my note names)====================================================FURTHER DEVELOPED BY: Nigel Garvey 2017-03-21/22/23, based on information in the Evernote fora, to allow a choice of Notes source folder(s) and to handle attachments.CAVEATS:1. I don't have Evernote and can't test that part of the code.2. (No longer relevant. Thanks to Yvan Koenig for the fix.)3. Any attachments are simply "appended" to the Evernote notes in the order they happen to be returned by Notes.4. The effect in Evernote of Notes's references to the attachments in the note HTML is unknown.*)main()on main()-- User choice of one or more Notes folders (by name).tell application "Notes"activateset folderNames to name of foldersset chosenFolderNames to (choose from list folderNames with multiple selections allowed)if (chosenFolderNames is false) then error number -128 -- Cancel button.end tell-- Preset HFS and POSIX versions of a path to a folder on the desktop for storing any attachments.set tempFolderPath to (path to desktop as text) & "Attachments from Notes:"set tempFolderPosix to quoted form of POSIX path of tempFolderPath-- Repeat with each chosen folder name:repeat with i from 1 to (count chosenFolderNames)-- Get all the notes in the folder with this name.set thisFolderName to item i of chosenFolderNamestell application "Notes" to set theNotes to notes of folder thisFolderNameset quotedFolderName to quoted form of thisFolderName-- Repeat with each note in the folder:repeat with j from 1 to (count theNotes)set thisNote to item j of theNotestell application "Notes"-- Get the relevant note data.set myTitle to the name of thisNoteset myText to the body of thisNoteset myCreateDate to the creation date of thisNoteset myModDate to the modification date of thisNoteset myAttachments to the attachments of thisNote-- Any attachments will need to be extracted to the folder on the desktop and attached to the Evernote note from there.-- To preserve the attachment names and avoid confusion in the case of duplicated names, each attachment is saved to a separate subfolder in a hierarchy based on the folder/note/attachment structure.set attachmentFiles to {}set attachmentCount to (count myAttachments)if (attachmentCount > 0) then-- If this note has any attachments, create or add to the hierarchy of the folder on the desktop to accommodate each one.do shell script ("mkdir -p " & tempFolderPosix & quotedFolderName & "/'Note '" & j & "/'Attachment '{1.." & attachmentCount & "}")-- Repeat with each attachment:repeat with k from 1 to attachmentCountset thisAttachment to item k of myAttachments-- Put together a specifier for a file in which to save this attachment.set thisFile to (tempFolderPath & thisFolderName & ":Note " & j & ":Attachment " & k & ":" & thisAttachment's name) as «class furl»-- Create the file before trying to save to it. (Suggested by Yvan Koenig.)close access (open for access thisFile)-- Save the attachment to it.save thisAttachment in thisFile -- Now it works! Thanks, Yvan!-- Store the file specifier for the retrieval of the attachment below.set end of attachmentFiles to thisFileend repeatend ifend telltell 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 myTextrepeat with thisFile in attachmentFilestell myNote to append attachment thisFileend repeatset the creation date of myNote to myCreateDateset the modification date of myNote to myModDateend tellend repeatend repeatend main
Комментариев нет:
Отправить комментарий