Function: trashed-tag-files-by-date
trashed-tag-files-by-date is a natively compiled function defined in
trashed.el.
Signature
(trashed-tag-files-by-date TAG &optional CONDITION PROMPT)
Documentation
TAG all files matching date condition CONDITION.
If CONDITION is nil, read it using read-regexp with a prompt beginning with
PROMPT.
CONDITION must consist of <(before) or >(after), and N days ago.
For example, <365 means tag all files deleted before the day 1 year ago,
>30 means tag all files deleted after the day 1 month ago,
>1 means tag all files deleted today.
Source Code
;; Defined in /nix/store/7ppdacjhnynz276lxxnfw8sdz6r2k6h2-emacs-packages-deps/share/emacs/site-lisp/elpa/trashed-20230811.157/trashed.el
(defun trashed-tag-files-by-date (tag &optional condition prompt)
"TAG all files matching date condition CONDITION.
If CONDITION is nil, read it using `read-regexp' with a prompt beginning with
PROMPT.
CONDITION must consist of `<'(before) or `>'(after), and `N' days ago.
For example, `<365' means tag all files deleted before the day 1 year ago,
`>30' means tag all files deleted after the day 1 month ago,
`>1' means tag all files deleted today."
(let* ((now-list (current-time))
(now (+ (ash (car now-list) 16) (cadr now-list)))
(n 0)
comp past datestr date)
(or condition
(setq condition
(read-string (concat prompt
" files (`<'(before) or `>'(after),"
" and `N' days ago): "))))
(if (not (string-match "^ *\\(\<\\|\>\\) *\\([0-9]+\\) *$" condition))
(error "Wrong date condition format")
(setq comp (if (string= (match-string 1 condition) "<") '< '>=)
past (- now (* 60 60 24 (- (string-to-number
(match-string 2 condition))
(if (eq comp '<) 0 1))))
past (apply 'encode-time (append '(0 0 0) ;; remove hour/min/sec
(cdddr (decode-time past))))
past (+ (ash (car past) 16) (cadr past)))
(save-excursion
(trashed-reset-vpos)
(while (tabulated-list-get-id)
(setq datestr (aref (tabulated-list-get-entry) 2))
(string-match "\\([0-9]+\\) \\([0-9]+\\)" datestr)
(setq date (+ (ash (string-to-number (match-string 1 datestr)) 16)
(string-to-number (match-string 2 datestr))))
(when (funcall comp date past)
(tabulated-list-put-tag (char-to-string tag))
(setq n (1+ n)))
(forward-line)))
(message "%d matching files." n))))