Elisp create today log files

Using elisp create a empty log file by today date

(defun my/create-today-log ()
  (interactive)
  (let (log-file)
    (setq log-file
          (concat "~/notes/"
                  (format-time-string "%Y-%m-%d")
                  ".org"))
    (when (not (file-exists-p log-file))
      (progn
        (write-region "* Notes" nil log-file)))

    (find-file log-file)))

Futhermore, we can using command to call this function

emacs --batch -l ~/.emacs.d/init.el --eval '(my/create-today-log)'

Date: 2024-11-18 Mon 00:00

Author: Terry Fung

Created: 2025-03-02 Sun 22:47

Emacs 29.4 (Org mode 9.6.15)

Validate