Home » Questions » Computers [ Ask a new question ]

What's a good solution for file-tagging in linux? [closed]

What's a good solution for file-tagging in linux? [closed]

I've been looking for a way to tag my files and search/filter them based on those tags.

Asked by: Guest | Views: 112
Total answers/comments: 5
Guest [Entry]

"It's not clear what kind of searching you want. If you want it to work anywhere in unix, rather that just your home directory, and you only want to do pathname-based searches, the following scheme is workable, with a little bit of shell hackery, and using the standard locatedb:

Each directory that contains at least one tagged file needs a standard subdirectory, say .path-tags;
Each file in the directory $FILE with link $TAG (which should not contain the char _) has a link $TAG_$FILE -> ../$FILE

I leave the details of the locate-tag script to you; it should be a two- or three-liner, using only the locate command and shell hackery. (If you're interested, I could write one).

Some of the KDE chaps talked about this sort of scheme for metadata, although I don't recall the details.

It should also be possible to do more sophisticated, content-examining tests based on this scheme with a similar script wrapped around find.

Thoughts on updated requirements

any file readable by the user can be tagged freely - Yes, should be no problem
a user can search for files matching one or several tags - Likewise
files can be moved around without losing the previously associated tags - The directories they inhabit can be freely moved about, but if the file is moved from the directory, we are in trouble. If the tags took the form $TAG_$INODE_$FILE and we have an efficient way to find which paths have a given inode, then we can do this, losing tags only if we move out of filesystems. Copying files might make some trouble, and this is clearly more complicated than my original suggestion.
the system could be backed up easily - not essentially difficult.
no dependencies on any desktop environment - none
if any gui is involved, there must be a cli fallback - that's where we live!

The ""reverse-inode-lookup"" file described by the link (2) you showed me in your answer to (1) can be used to give some additional infrastructure. We can run a service on the reverse lookup file, which checks that each inode given in the filename of a tag matches the inode of the file (if any) the tag points to. If there is no match, then the required surgery can be performed (does the inode still exists? where is it?), and the reverse lookup file being either mutated or regenerated, and the tag symlinks being updated.

I anticipate one tricky case: what if the tagged file is not where the tags say it should be, the reverse lookup file says it still exists, but the prodigal file is not where the lookup file says it is, the lookup file being out of date? There are a few ways to handle this case, none obviously ideal. Apart from this, this whole task seems to be the kind of thing Perl is well-suited to..."
Guest [Entry]

"Nobody mentioned, but you definitely should look at extended file system attributes.
ext4 for example has them. there are tools getfattr and setfattr to deal with them.
Of course you will have to write some shell scripts to search for files tagged with sometag.
Regarding mentioned questions all the answers are ""Yes"". You should only take into account that it's depended on file system."
Guest [Entry]

You probably don't need to install entire KDE desktop for their tagging library, Nepomuk. You would still have to install KDE base libraries, though...
Guest [Entry]

"This recent article on Linux Desktop Search Tools mentions that Tracker supports tagging. Unfortunately it's supposed to be half-broken in the old version they tested. Maybe it's fixed now?

Not system wide.
You can back it up.
It's bundled with Gnome."
Guest [Entry]

"Try Beagle. I find it is pretty good.

It may not meet all the requirements, and I'm not sure what could. For example, do FIFO files support extended attributes? If they don't, Beagle has a fallback database."