[Gllug] Tagging files on the command line?

Tom Schutzer-Weissmann trmsw at yahoo.co.uk
Sat Nov 18 20:56:20 UTC 2006


On Sat, 2006-11-18 at 20:01 +0000, Russell Howe wrote:
> On Sat, Nov 18, 2006 at 07:03:16PM +0000, Tom Schutzer-Weissmann wrote:
> > Does anyone know of a good way to tag files (and then locate them by
> > tags), preferably one that'll let me do it on the command line?
> 
> A bit low-tech, but how about the following?
> 
> $ mkdir tag1 tag2 tag3
> $ ln -s file tag1/file

It's so low-tech I like it, but then you have the inevitable problem:

$ mv file somewhere_else/

So either you include meta-information with the file or you wrap the
tools that manipulate the files. In my case that would be to use ext3
extended attributes, or alias "mv", "rm", and friends.

Leaftag comes with something called tagutils, which has a third, simple
approach: do nothing. If the file isn't where it was when it was tagged,
it's, um, not there:

~$ touch foo
~$ tagutils tag "tagged" foo
~$ tagutils ls "tagged"
/home/tom/foo
~$ mv foo foo2
~$ tagutils ls "tagged"
~$    

I've just been experimenting with ext3 extended attributes:
~$ setfattr -n user.tags -v tagged foo
~$ getfattr -n user.tags foo
# file: foo
user.tags="tagged"

~$ mv foo foo2
~$ getfattr -n user.tags foo2
# file: foo2
user.tags="tagged"

... but now searching by tags is more difficult and it'll be slower
because there's no database. So maybe "locate" could be made aware of
extended attributes, or maybe I could use inotify, or maybe I should
just say no to unworkable megalomania :)

TomSW


Send instant messages to your online friends http://uk.messenger.yahoo.com 
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list