Org-Mode - How do I create a new file with org-capture?
emacs, org-mode
Solution
You'll have to use `(read-string ...)` in `capture-report-data-file` to generate the filename on the fly.
(defun capture-report-date-file (path)
(let ((name (read-string "Name: ")))
(expand-file-name (format "%s-%s.txt"
(format-time-string "%Y-%m-%d")
name) path)))
'(("t"
"todo"
entry
(file (capture-report-date-file "~/path/path/name"))
"* TODO")))
This will prompt on capture for the file name, and then open the capture buffer will be created.
Problem
I want to create an org-capture template that create a dynamic file name for capture in emacs org-mode. I want that the name of the file takes the following form: (format-time-string "%Y-%m-%d") "-" (prompt for a name) ".txt" Example : 2012-08-10-MyNewFile.txt Based on this answer, I know how to dynamically create the name the file to include the date: ``` `(defun capture-report-date-file (path) (expand-file-name (concat path (format-time-string "%Y-%m-%d") ".txt"))) '(("t" "todo" entry (file (capture-report-date-file "~/path/path/name")) "* TODO"))) ``` This allows me to create a file 2012-08-10.txt and to insert * TODO at the first line How could I add a prompt to complete the file name?