Search code examples
templatesorg-mode

Creating a new text file in a diretory using org-capture


Following this response: Org-Mode - How do I create a new file with org-capture?

I am trying to make this piece of code work, but I get the error: invalid file location: nil.

(defun capture-report-data-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")))

Solution

  • Actually, it works like this:

    Replace

    (file (capture-report-date-file  "~/path/path/name"))
    

    with

    (file (lambda () (capture-report-date-file  "~/path/path/name")))