emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Karl Voit <news1142@karl-voit.at>
Cc: emacs-orgmode@gnu.org
Subject: Re: :EXPORT_FILE_NAME: containing a date-stamp
Date: Wed, 07 Feb 2018 16:41:01 +0000	[thread overview]
Message-ID: <CAFyQvY1hBkiTqL22Jf3b0erqRqi2d_-DOSxfPSnYsSgZpcQMNw@mail.gmail.com> (raw)
In-Reply-To: <2018-02-07T16-21-12@devnull.Karl-Voit.at>

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

On Wed, Feb 7, 2018 at 10:33 AM Karl Voit <devnull@karl-voit.at> 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

[-- Attachment #2: Type: text/html, Size: 2023 bytes --]

  reply	other threads:[~2018-02-07 16:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 15:31 :EXPORT_FILE_NAME: containing a date-stamp Karl Voit
2018-02-07 16:41 ` Kaushal Modi [this message]
2018-02-07 17:05 ` Berry, Charles
2018-02-07 17:37   ` Kaushal Modi
2018-02-07 18:06     ` Berry, Charles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY1hBkiTqL22Jf3b0erqRqi2d_-DOSxfPSnYsSgZpcQMNw@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@karl-voit.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).