How to preserve create time and modification time while importing?

How to preserve create time and modification time while importing?

I have lots of “md” files created by iA Writer, and I would like to importing all of them to Drafts. But the only problem is all these drafts would be “created” now, which ruined my review process and workflow on my drafts. I would like the “created” and “modified” timestamp to be the same as the file’s info.

I tried use “automatic import” feature, and the “scripting” too. The “FileManager” class does not have any method to retain file info.

So is it possible to achieve that? Thanks

Update:

Cannot change draft’s created time and modified time through scripting too

The only way to import creation/modification date information currently is via Drafts native JSON export format. Which looks like:

[
  {
    "created_at" : "2020-02-24T13:45:57Z",
    "tags" : [

    ],
    "accessed_at" : "2020-02-24T13:45:57Z",
    "uuid" : "39EA5821-A1A5-4DE6-AD06-F17381A24D85",
    "folder" : 0,
    "languageGrammar" : "Markdown",
    "created_latitude" : 0.00000,
    "modified_longitude" : 0.00000,
    "content" : "Test Draft",
    "flagged" : false,
    "modified_latitude" : 0.00000,
    "created_longitude" : 0.00000,
    "modified_at" : "2020-02-24T13:46:04Z"
  }
]

If you created this format outside of drafts, named the file with a .draftsExport extension, and import it you would retain the date information.

It not necessarily a bad idea to allow script access to some date values, but no one has ever requested it, and it presents some complexity to avoid the automatic mechanisms for maintaining and updating those values from conflicting with manually set values.

2 Likes

Thanks so much for this workaround.

And thanks for creating this awesome app too. It actually simplified my whole workflow so well. That’s why I’d like to import all of my texts to it to keep unification.

I am trying to import text files using this method, going from Day One JSON to Drafts. How can I create the UUID for the drafts JSON? I’ve got all the other keys mapped from the Day One JSON output to the Drafts JSON import, but Day One uses a different UUID format.

Thanks!

Drafts will generate a new UUID when importing, so I think you can just leave that blank or omit the key.

1 Like

I can confirm that this works. Thanks!

1 Like