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

It’s all pretty much right there in the title. I wish to be able to create a random note without having to think of a filename or anything at all. Just create the note with a single command and allow me to write in it. I can always rename it later on if I want. Is it possible to achieve that?

Thanks!

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

that is very useful for me. Thank you very much.

1 Like

Thanks! I tested it and I think that will work just fine for what I want.

1 Like