Finding tagless files with tmsu

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.

August 13 2014 01:49 pm | Tech

2 Responses to “Finding tagless files with tmsu”

  1. pocha Says:

    Thanks for the tip.
    Almost the same I use XAMPP on localhost to build web-based e-book manager. Apache + PHP + MySQL, with JQuery for GUI.
    Run in browser, it can add/delete e-book/folder to database, search based on title/author as well some advanced search features such as whole-word/case-sensitive.
    I have thousand of titles, mostly computer programming, but also other interests (humanities, food/recipes, arts/painting, knitting, sewing, etc.)
    Love you.

  2. Paul Ruane Says:

    Sorry to hear you had problems identifying your untagged files. The easiest way of doing so in TMSU v1.4 is to use the ‘status’ subcommand:

    $ tmsu status some/path | grep ^U

    When TMSU v1.5 is released there will be a dedicated subcommand ‘untagged’ for this purpose.


Leave a Reply