help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

deleting backup files dependant on their age


From: Sharon Kimble
Subject: deleting backup files dependant on their age
Date: Mon, 23 Nov 2015 19:46:31 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

I'm revisiting the age-old problem of deleting backup files, where
currently I have 1,383 which is increasing day-by-day. I have this in my
init.org -

--8<---------------cut here---------------start------------->8---
(setq backup-directory-alist '(("." . "~/.emacs.d/backups/"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 2
kept-old-versions 1)
--8<---------------cut here---------------end--------------->8---

but it doesn't seem to be deleting the old files.

So I've googled and found this on
http://www.emacswiki.org/emacs/BackupDirectory

--8<---------------cut here---------------start------------->8---
(message "Deleting old backup files...")
(let ((week (* 60 60 24 7))
      (current (float-time (current-time))))
  (dolist (file (directory-files temporary-file-directory t))
    (when (and (backup-file-name-p file)
               (> (- current (float-time (fifth (file-attributes file))))
                  week))
      (message "%s" file)
      (delete-file file))))
--8<---------------cut here---------------end--------------->8---

which I've amended to only work on files older than 14 days

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
(message "Deleting old backup files...")
(let ((fortnight (* 60 60 24 14))
      (current (float-time (current-time))))
  (dolist (file (directory-files ~/.emacs.d/backups t))
    (when (and (backup-file-name-p file)
               (> (- current (float-time (fifth (file-attributes file))))
                  fortnight))
      (message "%s" file)
      (delete-file file))))
#+end_src
--8<---------------cut here---------------end--------------->8---

but its failing to work, saying this -

╭────
│Symbol's value as variable is void: ~/.emacs.d/backups
╰────

How then can I set up auto-delete backup files for older than 14 days
which are held in "~/.emacs.d/backups" please?

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
Debian 8.0, fluxbox 1.3.7, emacs 24.5.1

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]