Deleting Garbage Files

John D. Cook who, among other things, publishes the TeX Tips Twitter feed, is an Emacs user and has a useful tip for cleaning up “garbage files”. Garbage files are intermediate files that can easily be regenerated. Examples are the .log and .aux files generated by TeX and LaTeX.

The secret is to type % & in Dired. It will mark the garbage files for deletion that can subsequently be deleted by typing x. This being Emacs, what constitutes a “garbage file” is, of course, configurable. The % & invokes dired-flag-garbage-files which flags files that match the regular expression in dired-garbage-files-regexp.

I vaguely remember this and I think I even wrote about it some time in the past. The problem is that if you don’t use it a lot, it’s hard to rediscover. It is, in fact, on the Dired Reference Card but the explanation is “flag various intermediate files”, which is technically correct but doesn’t suggest what it’s really used for.

In any event, it’s good to be reminded of it especially if you use LaTeX or some other application that generates intermediate files that you don’t want to save. It’s also another reason to learn and use Dired if you aren’t already.

This entry was posted in General and tagged . Bookmark the permalink.