emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] :EXPORT_FILE_NAME: containing a date-stamp


From: Kaushal Modi
Subject: Re: [O] :EXPORT_FILE_NAME: containing a date-stamp
Date: Wed, 07 Feb 2018 16:41:01 +0000

On Wed, Feb 7, 2018 at 10:33 AM Karl Voit <address@hidden> wrote:
:EXPORT_FILE_NAME: (format-time-string "%Y-%m-%d") Project Status.html

Yes, you cannot do that (How would Org know that you do not want to name your file literally like that? :)).

Also you do not need to (should not?) provide the file extension there.. the correct extension is added based on the exporter you use.

That said, I quickly tested this out, and it works:

(defun modi/org-advice-prefix-export-file-name-with-date (orig-fun &rest args)
  "Prefix the output file name with current date."
  (let* ((date-format "%Y-%m-%d")       ;Customize this variable as you like
         (date-file-separator "-")      ;Customize this variable as you like
         (orig-output-file-name (apply orig-fun args))
         (orig-output-dir (file-name-directory orig-output-file-name))
         (orig-output-just-file-name (file-name-nondirectory orig-output-file-name))
         (date (format-time-string date-format (current-time))))
    (concat orig-output-dir date date-file-separator orig-output-just-file-name)))
(advice-add 'org-export-output-file-name :around #'modi/org-advice-prefix-export-file-name-with-date)
;; (advice-remove 'org-export-output-file-name #'modi/org-advice-prefix-export-file-name-with-date)


After evaluating the above, current date will be prefixed to the exported file name, whether you export the whole file or just a subtree.
--

Kaushal Modi


reply via email to

[Prev in Thread] Current Thread [Next in Thread]