I’m migrating my notes into Drafts and wanted to know if there’s a way to bulk import .md files while also preserving the date/time of the file? Every time I import notes, they get lumped to the top of my list and set to today’s date/time.
As Andreas notes, the creation property is read only for scripting, and as you’ve noted, the standard non-scripting import processes create “now” and so the timestamps reflect that.
There is a way to do it, but it needs a bit of work to do:
Now, it would be possible on the Mac to build an automation to convert a file into a Drafts json file ready for import. Pretty much any scripting language is going to let you read file meta data (creation date, etc.) and write it out to a text file with the content and some standard text to create the JSON. The ease of doing so just depends on what tools or scripting languages you are comfortable working with, and how well suited they are to this sort of thing.
awesome thanks everyone. I’ve got got a lot of programming experience, so should be easy. one question: where can I export as JSON from Drafts so I can see what the format looks like? I can only see export as plain text as an option in the latest app.
thanks! I’ve actually got a small python app that will create my JSON from a directory of .md files. However, when I try and import a test note, I get the following message:
Looks pretty close. You need a tags: [ ] key, even if not assigning tags and the dates should be valid ISO 8601 dates, which need a time zone specifier…which means just add a Z at the end if your dates are already UTC dates.
[Update: Also, the long/lat should be numbers, not strings. Do not wrap them in quotes]
Hi @gcaprio, I am missing something in the import step in drafts. Neither the ‘Import …’ menu nor the Drafts/Inbox folder seems to work.
it only imports my json and does not create to drafts.
Yep. ISO 8601 has two possible ways to define the time zone. Python picks the other than drafts. A simple replace fixes this. Now it works. Thanks Greg.