Many times I capture stuff into my general inbox.org file. Some of those entries later turn out to be notes that I want to keep, but don’t need to be their own note. Thus I would like to move them to the correct daily entry file.
I would like to figure out how to:
- get the date of the current note from the CREATED property
- see if a daily note for that date exists
- if it does, refile it (preferably to the correct time between notes with already existing CREATED properties)
- if it doesn’t, capture a new daily file with this note’s contents (leaving the note’s created property intact)
Has anyone else found a need for such a workflow? And if so, would you be willing to share your elisp-fu? 
Here’s some code I have that finds the daily file for a given date, and I think creates it if it doesn’t exist: doom.d/org-config.el at a7d12591576dad86f0e2412f39abe915247a746f · telotortium/doom.d · GitHub
I might have time to give a more detailed answer later.
I have a similar workflow - it’s not perfect (note the TODO
in there) and is a bit hard-coded (~/todo
is my org and org-roam dir), but it works for refiling from point to today, tomorrow, yesterday, selecting a daily, or a few other common refile targets:
;; from https://emacs.stackexchange.com/questions/8045/org-refile-to-a-known-fixed-location
(defun russ/refile-to (file headline)
"Move current headline to specified location"
(let ((pos (save-excursion
(find-file file)
(org-find-exact-headline-in-buffer headline))))
(org-refile nil nil (list headline file nil pos))
(switch-to-buffer (current-buffer))))
(defun russ/refile-to-daily (n)
;; TODO this seems to sometimes nest the `daily/` an extra time :/
(let ((file-s (format-time-string "~/todo/daily/%Y-%m-%d.org" (time-add (* n 86400) (current-time)))))
(save-excursion
(org-roam-dailies-capture-tomorrow n t)
;; TODO write the file?
)
(russ/refile-to file-s "new")))
(comment
(format-time-string "%Y-%m-%d.org" (current-time))
(format-time-string "%Y-%m-%d.org" (time-add 86400 (current-time)))
(format-time-string "%Y-%m-%d.org" (time-add (* (- 1) 86400) (current-time))))
(defhydra hydra-org-refile-daily (:exit t)
;; TODO refile to today's daily note, create if it doesn't exist
("t" (russ/refile-to-daily 0) "Today")
("y" (russ/refile-to-daily -1) "Yesterday")
("T" (russ/refile-to-daily 1) "Tomorrow")
("j" russ/org-refile-to-daily-note "To some daily note" :column "Filter"))
(defhydra hydra-org-refile (:exit t)
("r" org-refile "Org refile" :column "~/todo")
("t" (russ/refile-to "~/todo/projects.org" "Todos") "project.org/Todos")
("h" (russ/refile-to "~/todo/projects.org" "Hammock") "project.org/Hammock")
("i" (russ/refile-to "~/todo/icebox.org" "new") "To icebox.org")
("p" (russ/refile-to "~/todo/principles.org" "new") "To principles.org")
("d" hydra-org-refile-daily/body "To some daily note"))
Source from my config if you’re digging: dotfiles/+org-custom.el at master · russmatney/dotfiles · GitHub
1 Like