djsudduth / keep-it-markdown

Convert Google Keep notes dynamically to markdown for Obsidian, Logseq, Joplin and Notion using the unofficial Keep API. Also, import simple markdown notes back into Google Keep.
Apache License 2.0
494 stars 32 forks source link

Is there any way the exported markdown files can have their "date created" set to the keep note's "date created" that is written in the files themselves? #43

Open TylerDavidJames opened 2 years ago

TylerDavidJames commented 2 years ago

Love the script, thanks so much for saving me days of work! I like that I can add the date created and updated from the keep note to the end of the markdown file that it generates, but I'm wondering if there is any way to create a markdown file for each note that has customised metadata that says it was created on the date that the keep note it refers to was created. That way when you sort the exported markdown files in obsidian by date, you get the same view by most recently created notes that you see in keep's home page. I don't know much about creating files with custom metadata, so this might not even be possible. I was just curious.

djsudduth commented 2 years ago

Hmmmm.....interesting question. It is possible but not very easy - there are some python libraries that can modify the create date but doing this is tricky on multiple operating systems (windows, linux, mac). However, I could add a switch to sort and export notes by the Keep datetime order and delay the output so that notes are output in the markdown file create time order. In that case you could sort your Obsidian files in the same order as Keep even though they'd be the same export date.

I'm in the middle of refactoring the code right now - so this might be a while. But, after my changes, sorting by timestamps will be easier.

TylerDavidJames commented 2 years ago

That sounds great too! I noticed that the sort by date option in obsidian did leave some of my more recently created keep notes futher away on the list than my earliest created ones, because they were all exported within 3 minutes or so, and I think it went through them in order. So I think there is a rough version of what you are envisioning already happening naturally just depending on how slow the notes export.

benooye commented 1 year ago

Hello, as a simple hack, in the function _def keep_queryconvert(keep, keepquery, opts) Just modify the line: for note in notes: by the following one: for note in reversed(notes):

It will create the Mardown files in the reverse order starting by the oldest ones and finish by the new ones So in Obsidian you can sort by modified date and it will apears in the good order

Thanks a lot for the code it is very helpfull

djsudduth commented 1 year ago

@benooye - awesome! thx for the tip! I'm wondering if the speed of conversion sometimes doesn't keep them in reverse order - e.g. 10 md files with the same date/time stamp. What have you discovered? I was thinking of adding a file io change to set the md file date/time to the note create date/time.

benooye commented 1 year ago

Dear @djsudduth, for me, when notes are created in reversed order, when I display them in Osbidian and sort them by modified date I have the proper order so it is ok for me.

To have a better handling of file date and file modification and reflect note creation and modifed date, it seems os.utime() function in Python should be able to do that https://www.tutorialspoint.com/python/os_utime.htm