The Complete Computing Environment

Quickly Rename Captured Zettel Files


When I capture a web page using org-protocol to quickly annotate web pages the file names can be very long, and I rarely want to keep the same page title as the web page, at any rate. After annotating my file I can run this function, cce/org-roam-rename-file interactively and it will offer a list of titles, including the ROAMALIAS keyword entries, or rename it if there is only one.

(provide 'cce/org-roam-rename-file)
(defun cce/org-roam-rename-file (file)
    (if (org-roam-file-p)
      (ivy-read "File: " (ivy--sorted-files org-roam-directory)))))
  (let ((destination
         (concat org-roam-directory "/"
                  (let ((titles (org-roam-db--get-titles file)))
                    (if (> (length titles) 1)
                        (ivy-read "Rename to Which title?" titles)
                      (car titles))))
    (rename-file file destination)))