Archive for August, 2014

Finding tagless files with tmsu

August 13th, 2014 -- Posted in Tech | 2 Comments »

I have a vast ebook collection, and as ebook titles are not as descriptive as one would like when searching for books on a certain topic, I decided I needed a way to organize my books. I went with tmsu, a command line utility that keeps an sqlite database of files and associated tags. It does not require anything special, and because of the option to mount a virtual, tag-organized filesystem, it’s useable with any software you like.

So I went on and tagged a big part of my collection. In theory, when I add to my collection, I should tag those files right away. In practice, that does not happen. So I found myself looking for a way to list all untagged files in a directory.

tmsu added the –untagged handle for the ‘tmsu files’ command, to be used together with –path. Unfortunately, that does not work at this time though. It requires the –all argument, but that does not include the untagged files. So I started playing around with xargs. The problem here was that many of the file names include spaces, underscores, and other stuff that really does not belong in a file name. After a lot of trial and error, I came to this solution:

find . -maxdepth 1 -print0 | xargs -0 -eof tmsu tags | grep “: $”

Of course, if you want to list files in a subdirectory too, you should change the -maxdepth argument. I added an alias for this, as I’m not going to remember it. I hope this saves you a long search.