all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function: rcd-find-latest-pictures-in-directory
@ 2024-12-05 13:29 Jean Louis
  0 siblings, 0 replies; only message in thread
From: Jean Louis @ 2024-12-05 13:29 UTC (permalink / raw)
  To: Help GNU Emacs

I have just finished this function and find it very interesting:

(defun rcd-find-latest-pictures-in-directory (directory &optional count)
  "Return the latest .webp, .png, .jpg or .jpeg picture in DIRECTORY.

Optional COUNT will return only specified number of pictures."
  (let* ((files (directory-files directory t "\\.\\(webp\\|png\\|jpe?g\\)$" t))
	 (latest-files (sort files
                             (lambda (a b)
                               (time-less-p (nth 5 (file-attributes b))
                                            (nth 5 (file-attributes a)))))))
    (cond (count (seq-take latest-files count))
	  (t latest-files))))

It will be used to quickly fetch latest downloaded picture, sort it
somewhere, optimize it for the website, and upload it. It is for
workflow optimization.

Jean Louis



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-05 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-05 13:29 Function: rcd-find-latest-pictures-in-directory Jean Louis

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.