unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

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).