tmsu: Guten Tag!

I got an e-mail from Paul a month or so ago, asking politely if I’d look over his tmsu program. I’m glad I did; it’s one of the niftier things I’ve come across for file management in the past year or so.

tmsu is a tagging tool, and a lot more. That might not sound too impressive at first (it didn’t to me), but I’ve had it installed for the past week or so, and I’m quickly becoming addicted to it.

What’s that mean — a tagging tool? Well, no doubt you’ve seen posts on this site that have tags at the bottom; I try to add tags that are vaguely related to the content, so you (or I) can search on topic very easily. You can even enter it from the address bar, and get a list of posts on that tag.

tmsu does much the same for files, plus more. Here’s an example. I have a folder of files that are all jazz music files, in ogg format. I can tag a file with “jazz” and “music” like this.

kmandla@6m47421: ~/downloads/Revolution Void/Increase the Dosage$ ls
01 Invisible Walls.ogg       05 The Modern Divide.ogg      09 Accelerated Lifestyle.ogg
02 Factum par Fictio.ogg     06 Double the Daily Dose.ogg  10 Headphonetic.ogg
03 Habitual Ritual.ogg       07 Weekend Amnesia.ogg        11 Nebulous Notions.ogg
04 Effects of Elevation.ogg  08 Obscure Terrain.ogg

kmandla@6m47421: ~/downloads/Revolution Void/Increase the Dosage$ tmsu tag "01 Invisible Walls.ogg" music jazz

No reply from tmsu, but that just means all went well. Now I can find exact files that have that tag, just by asking tmsu.

kmandla@6m47421: ~/downloads/Revolution Void/Increase the Dosage$ tmsu files jazz
./01 Invisible Walls.ogg

tmsu knows where I am in the folder tree, and shows the location relative to that. If I move elsewhere, tmsu’s reply changes to reflect it.

tmsu can also tell me what tags are applied to a file.

kmandla@6m47421: ~$ tmsu tags downloads/Revolution\ Void/Increase\ the\ Dosage/01\ Invisible\ Walls.ogg 
excellent  jazz  music

kmandla@6m47421: ~$ 

So, what’s so great about that? Well, it means I can tag a file with anything — dates, genres, contributing artists, release date, operating system, file format, program version, codebase, first initial, creator, download site, language, subtitles, video quality, personal ratings, prices, origin — you name it. And not just music files — anything. Plus, you’re not beholden to a rating system, application or specific mark as a tag. Tag it with whatever you like, not just what id3v9.1a says is a legitimate category for an mp3 file. πŸ™„

Here’s a rough example, using personal ratings of excellent, very-good, good, and poor, which is just arbitrary. I’ve abbreviated the lists considerably, of course.

kmandla@6m47421: ~$ tmsu files excellent
./downloads/Revolution Void/Increase the Dosage/01 Invisible Walls.ogg
./downloads/Revolution Void/Increase the Dosage/11 Nebulous Notions.ogg

kmandla@6m47421: ~$ tmsu files poor
./downloads/Revolution Void/Let 1,000 Flowers Bloom/01 Sympathy for Mr Vertigo.ogg
./downloads/Revolution Void/Let 1,000 Flowers Bloom/28 Ye Ye Ye.ogg

Those would all show up if I asked for “jazz” or “music” too, because I added those tags as well.

Now, if that didn’t grab you, here’s where tmsu suddenly changes from mild-mannered scientist into a giant green unstoppable mountain of muscle.

tmsu can mount a folder as a virtual filesystem, and create symbolic links that point back to the original file. Take a look.

kmandla@6m47421: ~$ tmsu mount temp/

kmandla@6m47421: ~$ ls temp/
queries  tags

The tags folder is probably the most obvious one: Inside that folder are all the tags you’ve created, and links back to their target files.

kmandla@6m47421: ~$ ls temp/tags/
alternative  excellent  good  hip-hop  jazz  music  poor  rap  rock  soul  very-good

kmandla@6m47421: ~$ ls temp/tags/excellent/
01 Invisible Walls.410.ogg       05 The Modern Divide.413.ogg      09 Accelerated Lifestyle.405.ogg  music
02 Factum par Fictio.404.ogg     06 Double the Daily Dose.412.ogg  10 Headphonetic.414.ogg
03 Habitual Ritual.406.ogg       07 Weekend Amnesia.408.ogg        11 Nebulous Notions.407.ogg
04 Effects of Elevation.409.ogg  08 Obscure Terrain.411.ogg        jazz

The numbers are file IDs, and the additional tag folders — “jazz” and “music” — point back to still more links. So I can sift even further into specific sequences of tags by following the folders, and for example, find “excellent/jazz/music”. πŸ˜‰

That’s pretty cool, and if you have a massive collection of music or photos to manage, it will save you gobs of time and effort. But wait, there’s more. …

That other folder, queries … what about that? Let me show you first, and then we’ll try to puzzle it through.

kmandla@6m47421: ~$ ls temp/queries

kmandla@6m47421: ~$ ls temp/queries/excellent
01 Invisible Walls.410.ogg       05 The Modern Divide.413.ogg      09 Accelerated Lifestyle.405.ogg
04 Effects of Elevation.409.ogg  08 Obscure Terrain.411.ogg

kmandla@6m47421: ~$ ls temp/queries/

I abbreviated again, as you can see. My ls command created a folder inside queries, and inside there are links to everything that matches my request. Magical, on-the-fly searching and linking.

I haven’t tried using tmsu in conjunction with many graphical programs, but I believe you could create a folder inside queries from within a file selection dialog, and get the same results. I’d be interested to see how that works.

I haven’t found many shortcomings with tmsu; it appears to be very well thought out, and behaves in a very Unixy way. My biggest stumbling block was a way to tag an entire folder of files with spaces in their names; the spaces were confusing tmsu and my use of quotes wasn’t helping matters.

In the end I solved it in a similarly Unixy way, by drafting find into service:

find downloads/Revolution\ Void/ -type f -exec tmsu tag "{}" music jazz \;

And that was more than enough to get the job done.

I only have about 8Gb of music that I keep, and I don’t have much in the way of photos except for family snapshots. tmsu has made me think about how I store those though, and made me wonder if the endless branches of folders are really helping.

I would strongly recommend experimenting with tmsu if you have large masses of files that need quicker access than through a file tree, or even just as a way of managing a flat folder of files without resorting things into subfolders. Check it out for a few minutes at least, and see if it can make things easier for you. πŸ™‚

10 thoughts on “tmsu: Guten Tag!

  1. Eric Davis

    Nice one. I also use TMSU and it’s awesome. I use it for tagging the steady stream of technical docs that pile up in my home directory. When I get a new doc I immediately throw it in ~/docs and tag it with tmsu. The number of minutes/hours saved by doing this is remarkable.

    Other tagging filesystem helpers are:
    Tagsistant –
    Tagfs –
    Dantalian –

    They all have pros and cons. For me TMSU is the best and allows me to be the most productive. Some of those other ones I just fought with for a variety of reasons but are definitely worth mentioning and trying out.

    1. Theodore

      That tagfs is an interesting idea. I say that without even watching it lol, but it’s interesting.
      The tagging idea into filesystems is a very productive one, but I never had time to dig in that, preferring to tidy periodically my data. I wasted loads of time…
      Thanks for the links!

      1. K.Mandla Post author

        It took me a little bit to see the value in it, but even with my small collection I was impressed by what I could do with it. It’s definitely worth trying, even if you don’t end up using it. Cheers! πŸ˜‰

    2. Paul Ruane

      Paul here, author of TMSU. Thanks for looking at TMSU.

      As for tagging multiple files, you should simply be able to type:

      $ tmsu tag –tags=”music jazz excellent” *.mp3

      That should work even if your filenames contain spaces as your shell should automatically deal with the spaces when it applies the glob (wildcard). Alternatively you can use the -print0 option in ‘find’ and combine it with the -0 option in TMSU (or Xargs for that matter) to use the null character, rather than spaces, to delimit files.

      One point to mention, which you may not have noticed, is that the ‘queries’ directory allows you to run more complicated queries: the following lists files that have the ‘fish’ and ‘chips’ tags, but not the ‘vinegar’ or ‘peas’ tags:

      $ ls “mp/queries/fish and chips and not (vinegar or peas)”

      (the word ‘and’ can also be omitted for brevity)

      Anyhow, any questions or suggestions please get in touch. And thanks again for reviewing TMSU and taking the time to write this article.


  2. Pingback: tagsistant: Tagging with a different approach | Inconsolation

  3. Pingback: tagsistant: Tagging with a different approach | Linux Admins

  4. Pingback: tagfs, xtagfs, dhtfs and more: Tag, you’re it | Inconsolation

  5. Pingback: tagfs, xtagfs, dhtfs and more: Tag, you’re it | Linux Admins

  6. Pingback: Bonus: 2014 in review | Inconsolation

Comments are closed.