who can develop a small apple script to copy my notes content into a Ninox's text field
Ninox Profile

i'd like to copy each note i have in macos notes in a text field in ninox

i don't want to do that manually since i have more than 700 notes… !!

i never learned how to work with apple script but i guess it can handle the job ?

anyone can help ? thanks a lot !

Ninox Profile

You should get the notes exported as a csv file and import this into Ninox as described here:
https://ninoxdb.de/en/manual/import-and-export/import-data

Birger

Ninox Profile

DISCLAIMER.. I have not used appleScript very much.. I pieced the following together from various sites.. I tried to reference them.. 

To use the script.. Create a Notes Ninox database with fields for folder, create date, modified date, note body...

NOTE... in the notes.app .. the note body is in HTML .. so I also create a function field using the html function on the note body.. 

Here is the appleScript.. Let me know how it works for you. 

(*

============================================

Export Notes to TEXT file in CSV format

============================================

 


Date: 2018-08-31

Author: M.Conneen

 


References:

https://www.macosxautomation.com/applescript/sbrt/sbrt-09.html

https://www.macosxautomation.com/applescript/sbrt/sbrt-06.html

https://gist.github.com/jthigpen/5067358

https://stackoverflow.com/questions/28115085/find-and-replace-in-applescript

https://macscripter.net/viewtopic.php?id=37908

 


How to use:

Close notes app

run script

file My Apple Notes.txt will appear on your desktop.. depending on how many notes you have, may run for a while.

Ignores attachments.

*)

main()

 


on main()

set hdr to "folder,name,create date,modificaiton date,note" & "

"

set this_file to (((path to desktop folder) as string) & "My Apple Notes.txt")

my write_to_file(hdr, this_file, false)

tell application "Notes"

repeat with aNote in notes

set c to (container of aNote)

set noteText to "\"" & (name of c as string) & "\","

set noteText to noteText & ("\"" & name of aNote as string) & "\","

set noteText to noteText & "\"" & (creation date of aNote as string) & "\","

set noteText to noteText & "\"" & (modification date of aNote as string) & "\","

set clnTxt to my replaceText("\"", "@", (body of aNote as string))

set clnTxt to my stripLF(clnTxt)

-- set clnTxt to (body of aNote as Unicode text)

set noteText to noteText & "\"" & clnTxt & "\"

"

my write_to_file(noteText, this_file, true)

 

end repeat

end tell

end main

 


on write_to_file(this_data, target_file, append_data)

try

set the target_file to the target_file as string

set the open_target_file to open for access file target_file with write permission

if append_data is false then set eof of the open_target_file to 0

write this_data to the open_target_file starting at eof

close access the open_target_file

return true

on error

try

close access file target_file

end try

return false

end try

end write_to_file

 


on replace_chars(this_text, search_string, replacement_string)

set AppleScript's text item delimiters to the search_string

set the item_list to every text item of this_text

set AppleScript's text item delimiters to the replacement_string

set this_text to the item_list as string

set AppleScript's text item delimiters to ""

return this_text

end replace_chars

 


on replaceText(find, replace, someText)

set prevTIDs to text item delimiters of AppleScript

set text item delimiters of AppleScript to find

set someText to text items of someText

set text item delimiters of AppleScript to replace

set someText to "" & someText

set text item delimiters of AppleScript to prevTIDs

return someText

end replaceText

 


on stripLF(inText)

set inText to inText's paragraphs

set d to AppleScript's text item delimiters --get original delimiters

set AppleScript's text item delimiters to ";"

set inText to inText as text

set AppleScript's text item delimiters to d --replace original delimiters

inText

end stripLF

Ninox Profile

A couple of screen shots.. 

notes2

notes

S

This is something I am willing to help you with, let me know if you are interested and I can send you an email. 

Ninox Profile

For the published script above.. Make sure notes.app is CLOSED (aka not running).. I got some strange results when the app was opened.

This is only a quick hack.. it does not address cleaning up the notes field from the exported html to the ninox multiline field.. Nor does it address converting the dates from text to dates.. or if the notes have any attachments.. etc.. 

Hope this helps.. It was fun to learn a bit of appleScript... I included references in the script.. if I missed any... please forgive me.. 

I do not see a way of attaching files within this forum.. You can grab the source and sample database from here. 

http://mconneen.infointegrators.net/ninox/NotesToFile.scpt

http://mconneen.infointegrators.net/ninox/Notes%20From%20Mac.ninox

 

Ninox Profile

hi all, i was away for a fiew days, but i'm back now !

thanks all for your help

birger, it was the non ninox part i was loocking for

mconneen, you've got it, i'm going to test it all for sure

s moore, all help is welcomed, you can send me an email

i'm going to look at the code soon and i'll try to get the attachments also

thanks again all

Ninox Profile

google for the attachment logic.. I recall seeing one that pulled the attachments and put them in named folders / subfolders on the desktop.   The script I published will at least xfer the notes into a CSV that can be imported..  

 

Reply