0

I am trying to figure out the best solution to tag files in GNU/Linux. This is the particular thing I am trying to achieve. I download all my movies and save them on the external SSD. I sort them in two directories: "watched" and "to_watch". However, I want to assign attributes to each movie such as (but not limited to): main actor(s), director(s), genre. That way, if I have a huge amount of files and I am in a mood to watch a movie directed by Scorsese, I can display only movies that contain a tag "scorsese".

Here are some of the requirements that I have:

  • I want the solution to be independent of my local computer being used. For example, if I take my external SSD to my friend who also has the Unix system (and installs the required solution for tags), he's computer will also be able to interpret all of the tags generated by me.
  • I want to have a CLI option.
  • If I change the file's location, the tag(s) still stays with the file.
  • I can assign multiple tags to the file.
  • I can tag a file of any format.
  • I can tag a directory as well (not only files).
5
  • You could keep your "tags" in a text file named the original filename with a ".tags" suffix. You'll have to be careful to move the .tags file along with the original.
    – waltinator
    Dec 18, 2021 at 19:36
  • @waltinator you know, file systems have a tool for that! Extended attributes! Dec 18, 2021 at 20:05
  • Media files usually have this kind of tagging built in. Are you sure that your media don't already have the information available?
    – roaima
    Dec 18, 2021 at 20:28
  • 1
    @roaima I am not sure, but even if they do I want to find a general solution to this because I can think of many scenarios where I want to tag any type of file.
    – Vladimir
    Dec 19, 2021 at 1:33
  • @waltinator I thought of a similar solution but it is really far from elegant.
    – Vladimir
    Dec 19, 2021 at 1:34

1 Answer 1

0

Two things:

1.

The more native way is of course to use a feature of many Unix file systems to save what is called extended attributes or just xattrs. You can query, set, modify and remove these attributes from files using the getfattr and setfattr command line programs (under Linux, don't know much about how *BSD deals with these); their man-pages should be interesting to you.

However, that's not really that useful – after all, you then have a lot of files that you somehow tagged with some information, but will need to sit on a console to try and get them out again.

So, what you actually need is not only a way of tagging files, you need something to actually do something useful with that information, manage it and so forth.

2.

What you describe is functionally a movie database, and as such, probably a media server is the most useful solution. If you can restrict the number of possible platforms to one (or maybe two) like x86_64 (and maybe arm64?), you could also just put a container on your external hard drive that just contains all that is needed to run the movie database software. So your friend can just start that (don't know what shape something like that takes – maybe a DLNA server?). I've got no experience with such things.

So, what I'd do, is actually sit down and write the software you want. Sounds crazy, but is quite OK, considering any modern PC-style hardware with a Unix on it will have access to some halfway modern Python3.

3.

As described above, you could use extended file system attributes to store the information about the file – within the file "filesystem entry" itself. That way it stays with the file when you move that on the drive.

However, since, as you said, you might want to run some kind of GUI/TUI from the external drive, anyways, there's not that much benefit to that. So, a simple SQLite database (sqlite3 comes with every Python installation) would do just fine. Then, you'd just write a short tool to look for the database file, look for the media files relative to that, then add some functions to scan for files that aren't yet part of the database, add them, maybe query from IMDB's API. Of course, a nice query interface would be nice, as well, so you could either go for "text adventure" style, or you could use Textual (new, exciting, probably a bit experimental) or urwid; both are pure Python, if I'm not mistaken, so running things should be trivial on different machines!

2
  • Thank you for taking the time to suggest a solution. I will look into it and try to make it work especially with Option 1. I have also found this: github.com/oniony/TMSU and I might consider it.
    – Vladimir
    Dec 19, 2021 at 1:38
  • 1
    @Vladimir yeah, that TMSU seems to be roughly what my "3." is! If you're planning to ship your media with software anyway, there's nicer things optimized for media storage/discovery, though I'm not much of a user of such. Dec 19, 2021 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.