Package to manage filetags in filename

convenience, files, emacs, tagging



Filetags is an Emacs package inspired by filetags which manages filetags directly in the filename. By default tags are space seperated words seperated from the rest of the filename by -- e.g.

image -- holiday italy.png

One can change the seperator between the filename and the tags as well as the seperator between the tags by customizing filetags-delimiter-between-filename-and-tags and filetags-delimiter-between-tags. This package provides a simple function to update these tags from the dired file browser and the option to restrict tags to a controlled vocabulary.

This is up until now just a hobby project to teach me elisp. So I am grateful for every feedback.


Clone this Git-Repository and load filetags.el


In dired call filetags-dired-update-tags to add or remove tags to multiple marked files or if no files are marked to the file on point. The User is then prompted for tags and kann add tags by entering “+tag”. If there are already tags present in one of the files the respective action to remove this tag “-tag” is proposed. The user can enter tag actions until he hits “Perform actions”. Then the tags are applied.

If one adds

(setq filetags-enforce-controlled-vocabulary t)
(setq filetags-controlled-vocabulary '(("winter" "summer") ("emacs")))

to one’s .emacs file, then only tags from the controlled vocabulary can be added to the files (plus tags which are already present in the filenames). filetags-controlled-vocabulary is a list of list of strings. Tags which are in the same list are mutually exclusive which means if one of those tags is added, all other tags of the same group are removed. When adding the tag winter to the following file:

test -- emacs summer.pdf

then it is renamed to

test -- emacs winter.pdf 

If filetags-enforce-controlled-vocabulary is nil then also other tags are accepted. If one sets

(setq filetags-load-controlled-vocabulary-from-file t)

then the vocabulary in filetags-controlled-vocabulary is ignored and the controlled vocabulary is loaded from the next .filetags file in the upper directory tree. The syntax of this file is equal to the one in filetags. One can add comments with # and multiple tags on the same line are mutually exclusive.

Handling of symbolic links

When changing the tags of symbolic links, the tags of the origin file are also changed. This works recursively for a chain of links. E.g., if one has a chain of links

link.pdf  ->  original-file.pdf
another-link.pdf  ->  link.pdf

adding the tag important to another-link.pdf changes the files to

original-file -- important.pdf
link -- important.pdf  ->  original-file -- important.pdf
another-link -- important.pdf  ->  link -- important.pdf

The other way round (when changing original-file.pdf does not work as one would have to scan the whole file system for links.

Related projects

Also inspired by novoids work: date2name.el