How can I create a random note with a random unique file name in one go?

Is this what you are going for?

(defun my/create-new-note ()
  "Create a new note file in `org-roam-directory'."
  (interactive)
  (let* ((time-string (format-time-string "%Y%m%dT%H%M%S"))
         (extension "org")
         (file-base-name (concat time-string "." extension))
         (file-name (expand-file-name file-base-name org-roam-directory)))
    (find-file file-name)
    ;; In the new buffer
    (insert (format "#+title: %s\n\n" time-string))
    (org-id-get-create)
    (end-of-buffer)))
1 Like