1.4 KiB
1.4 KiB
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 ROAM_ALIAS keyword entries, or rename it if there is only one.
(provide 'cce/org-roam-rename-file)
(defun cce/org-roam-rename-file (file)
(interactive
(list
(if (org-roam-file-p)
(buffer-file-name)
(ivy-read "File: " (ivy--sorted-files org-roam-directory)))))
(let ((destination
(concat org-roam-directory "/"
(org-roam--title-to-slug
(let ((titles (org-roam-db--get-titles file)))
(if (> (length titles) 1)
(ivy-read "Rename to Which title?" titles)
(car titles))))
".org")))
(rename-file file destination)))