Best way to add CREATION date to notes?

I am aware that individual files contain their creation date in their filenames. In addition to that, I am looking at adding a “creation” metadata to the notes – both file level roam nodes, and heading/subheading level roam notes.

What is the best way to go about doing that?

  • adding #+creation: to files? I don’t think that’s good, because the #+properties are filelevel properties that relate to exporting backends, afaik.
  • adding :CREATION:property to the property drawers of each and every roam node that gets created? This would both include the file level roam nodes and subheading/heading level roam nodes

Looking at the forum posts, I see:

  1. User contributed Tricks · org-roam/org-roam Wiki · GitHub –> this one seems to insert a non-standard (ie, neither is a #+ nor a drawer property) Time-stampmetadata to the file. But what about the subheading/heading roam nodes?
  2. Update a field (#+LAST_MODIFIED: ) at save - #18 by kevindb159 –> this one inserts #+modified using org time-stampfunctionalities. Again, what about the subheading/heading roam nodes&notes?

Concerns:

  1. getting it in a format that is properly working with the greater org ecosystem
  2. getting other roam-tools, like org-roam-ui to perhaps make sense of it and use it

I guess the easiest way to go about doing that would be changing the org-id-methodto ts value. That way, the UUIDs of ALL your roam nodes (both file level and subheading level) will automatically encode the UUID creation date.


But again, I don’t like changing an orgmode default setting (org-id-method) globally just ‘cuz I am using org-roam.

I do not see a problem. It is a customizing variable by org-id, which is part of the upstream. Where does your concern come from?

Other tools might not (whether now or in the future) work well with a somewhat more esoteric/non-default choice for org-id-method.

@ChuckSneed If you prefer to keep org-id default, and you want to avoid the #+ keyword, then… I think you have your own conclusion, don’t you? Use the property drawer.

I do, but I post here in this forum to see others’ opinions. It is not just me reaching my own conclusion on my own. Why have a forum then?

I agree with you about open exchange in a forum. My opinion about the “best way” is the one you find. If you are seeking others’ opinions, I’d suggest perhaps you could phrase your opening question differently, and directly ask for open opinions as you did now. This is only my view and you can agree or disagree with me.

Why? Best way can be subjective, and I was expecting that to be so. Anyways.. this is offtopic.

No worries. I see the “best way” you are asking is one’s own best way (eg nobiot’s best way he has found so far) not a way you ChuckSneed may find best.

My best way so far is:

  1. File nodes only (headings are not nodes)
  2. File name starts with a date stamp (up to minutes) but keep a title in the file name too
  3. Use Org ID as time stamp too (because I find UUID esthetically less appealing than a time stamp)
  4. I also add a file meta data with the time-stamp as described in the forum and Wiki.

There is also another reason why I prefer timestamps to UUID. I can use timestamps in my physical notes to refer to notes (from/to digital ones). It is not easy for my human eyes to use UUID as a reference key.

2 Likes

This might be useful to you. I add it to ALL headings in the org-roam nodes

(defun dmg-org-add-created-to-all-headings (&optional p)
  "Add a CREATED property with the current date to every heading without it."
  (interactive "P")
  (let ((date (if p
                  (format-time-string "%Y-%m-%d %T" (org-read-date nil t))
                (format-time-string "%Y-%m-%d %T"))))
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward org-heading-regexp nil t)
        (unless (org-entry-get nil "CREATED")
          (org-entry-put nil "CREATED" date))))))

and this is how I call it. If I want to add it to no-roam files I check DMG-ADD-CREATED property.

the function also adds an ID if the file is in the roam directory and it does not already have at least one ID.

(defun dmg-org-add-properties-before-save ()
  "Add CREATED property to headings and ID/TRIGGER to the file before saving.

  CREATED is added if org-roam file and not explicitly disabling it

                   if not org-roam file, then explicitly enabling it

  ID gets added if org-roam and first header does not have an id

  Any errors encountered are caught and reported, but do not abort the save."
  (condition-case err
      (let* (
            (file-props (dmg-org-roam-file-properties))
            (is-org-roam (org-roam-file-p))

            (created-prop (dmg-org-roam-file-property "DMG-ADD-CREATED" file-props))
            (explicit-add-created  (and created-prop
                                       (string= created-prop "yes")))
            (add-created (cond
                          (created-prop      explicit-add-created)
                          (is-org-roam      (not created-prop))
                          ))
            (id-prop          (dmg-org-roam-file-property "ID" file-props))
            (first-heading-id (dmg-org-first-heading-get-id))

            (add-file-id (and is-org-roam
                              (not id-prop)
                              (not first-heading-id)))
            )
        ;; 
      (when add-created
        (dmg-org-add-created-to-all-headings))
      (when add-file-id
        (dmg-org-file-add-id))
        )
    (error (message "Error adding properties: %s" (error-message-string err)))))

(add-hook 'before-save-hook 'dmg-org-add-properties-before-save)
1 Like

Thanks @dmg . For the record here’s also what I’ve been tinkering with:

(org-roam-capture-templates
   '(("d" "default" plain "%?"
      :target (file+head "pages/%<%Y%m%dT%H%M%S>--${slug}.org"
						 ":PROPERTIES:
:ID: %(org-id-new)
:CREATED: [%<%Y-%m-%d %a %H:%M>]
:END:
#+title: ${title}
#+filetags: :pages:
")
      :unnarrowed t)))

and

(org-roam-dailies-capture-templates
   '(("d" "default daily" entry
      "* %<%H:%M> %?
:PROPERTIES:
:ID: %(org-id-new)
:CREATED: [%<%Y-%m-%d %a %H:%M>]
:END:
"
      :if-new (file+head "%<%Y-%m-%d>.org"
						 ":PROPERTIES:
:CREATED: [%<%Y-%m-%d %a %H:%M>]
:END:
#+title: %<%Y-%m-%d>
#+filetags: :journals:%<%Y-%m-%d>
")
      :unnarrowed t)))

This way, both file nodes and heading nodes always have folllowing two properties in their :PROPERTIES: drawers:

  1. UUID (which is the default behavior)
  2. Creation date (which is my addition)

Yes, the templates are useful.

I create a lot of headings by hand. BUt I don’t want all headings to be org-roam nodes. It clutters searching for headings.

Usually, when I am editing a roam file, when I am adding heading. if I think I am likely going to visit it directly in the future (e.g. I think I will search for it), I call org-id-get-create manually to add the ID to convert it into an org-roam node.

1 Like

What about GitHub - tefkah/org-roam-timestamps: Add modified and creation timestamps to the org-roam property drawer ?

1 Like