all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* deleting backup files dependant on their age
@ 2015-11-23 19:46 Sharon Kimble
  2015-11-23 20:14 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sharon Kimble @ 2015-11-23 19:46 UTC (permalink / raw
  To: help-emacs

[-- Attachment #1: Type: text/plain, Size: 2134 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-25  1:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 19:46 deleting backup files dependant on their age Sharon Kimble
2015-11-23 20:14 ` Eli Zaretskii
2015-11-24  0:01 ` Emanuel Berg
2015-11-24  0:58 ` Emanuel Berg
     [not found] ` <mailman.585.1448326084.31583.help-gnu-emacs@gnu.org>
2015-11-24  4:46   ` Dan Espen
2015-11-25  1:26     ` Emanuel Berg

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.