- What’s a good solution for file-tagging in linux? [closed]
- 13 Answers 13
- Using the Lesser Known File Tagging Feature in KDE’s Dolphin File Manager
- Adding tags to files and folders in KDE
- Method 1: Adding tags through right-click context menu
- Method 2: Adding tags through the information panel
- Showing tag information of a file or folder
- Method 1: Show the associated tags under file name
- Method 2: Show associated tags in list view
- Listing all the files associated with a particular tag
- Searching for files with specific tags
- Sorting items according to tags
- Changing emblems of tags
- Removing tags
- Buggy feature: Copy a tag as a directory
- Wrapping Up
What’s a good solution for file-tagging in linux? [closed]
Questions seeking product, service, or learning material recommendations are off-topic because they become outdated quickly and attract opinion-based answers. Instead, describe your situation and the specific problem you’re trying to solve. Share your research. Here are a few suggestions on how to properly ask this type of question.
- any file readable by the user can be tagged freely
- a user can search for files matching one or several tags
- files can be moved around without losing the previously associated tags
- the system could be backed up easily
- no dependencies on any desktop environment
- if any gui is involved, there must be a cli fallback
I’ve been hoping for some basic filesystem & coreutils hackery to handle this, but I haven’ thought about this hard enough yet.
Meanwhile I’ll review beagle and metatracker, which have been mentionned here, and see how they perform.
Ok so beagle has huge gnome dependencies, and tracker is okish, but still has some dependencies I don’t like.
Been doing some more research, and the way to go could very well be extended file attributes.
That’s a native solution for most recent filesystems, but they aren’t very well supported yet (most coreutils destroys them by default, cp for example needs the -a flag to preserve them). Would like to hear some thoughts on using them while I try my hand at some hacks myself, eventhough this might warrant a new question.
Issues with extended file attributes: (i) In my experience, they are a nuisance when you want to backup. (ii) You can’t use them when you move between filesystems. Apart from that, they would be the Right Thing.
In PC-BSD Forums, with reference to the 2010 edition of this question: PC-BSD, extended attributes and tagging; OpenMeta and Apple’s approach
13 Answers 13
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!
Postscript 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.
Using the Lesser Known File Tagging Feature in KDE’s Dolphin File Manager
Dolphin is the default file manager of the KDE Plasma Desktop Environment. It is considered as one of the most comprehensive and feature-rich file managers available for Linux distributions.
Yes. It has tons of features and you may not be aware of all of them. One such feature is file tagging.
File tagging is a way of organizing files or folder by applying tags to them. This tag can then be used to search for data, and sort the files accordingly. With this feature, you can tag files into categories irrespective of their location. This gives you a new way to organize your files.
While there are dedicated tools like Tagspaces for this purpose, this feature comes baked into KDE’s Dolphin file manager.
In this tutorial, I’ll show you how to use the file tagging feature in Dolphin.
Adding tags to files and folders in KDE
There are two ways you can add tags:
Method 1: Adding tags through right-click context menu
Select the file(s) and folders to which you want to add tags. Now press the right click.
You need to select the “Add Tags” option and here, you can add the name of the tag, by pressing Create New.
You need to enter the name of the new tag and press OK.
Once created, the tag will be visible the next time you try to tag a file.
Also, you can toggle the check box according to your need to add or remove a file/folder from a particular tag.
Method 2: Adding tags through the information panel
Dolphin provides an information panel where you can view the details of a file/folder, including a small preview.
This is turned off by default. But you can enable it by going to Show Panel > Information from the top right hamburger menu.
Once this is checked, you will notice the new panel on the right side. Here, you can see the tags listed as an entry.
First, select the file/folder to which you want to add tags and then press Add on the information panel. Now, you can either create a new tag or add an existing tag to the respective file/folder, as shown in the above screenshot. Press Save once you are done.
The same information panel will also show the tag information of the selected items if it has any.
Showing tag information of a file or folder
As I mentioned above, the information panel lists the tags attached to the file/folder under selection. But there are more ways to list the tags. Those methods are detailed below.
Method 1: Show the associated tags under file name
On the default Icon View in Dolphin, you can get the tags associated with each item just beneath the name of that item.
Select Show Additional Information > Tags from the hamburger menu in the top right corner.
Once the box is checked, as shown in the above screenshot, you will notice that the tag information appears beneath the name of each item.
Method 2: Show associated tags in list view
Dolphin also provides a Detailed view. Here, the contents are listed with columns for each information.
By default, tag data column is not shown. To add that, you can right-click anywhere on the top column, as shown in the screenshot below. Now, check the tag box.
You will notice a new column, with tags of individual entries, is appeared.
By clicking on the tag button (blue rectangle in the screenshot), you can sort the entries of the current location according to tags (alphabetical or reverse).
Listing all the files associated with a particular tag
If you have many tags, you may want to list all the files and folders associated with a particular tag.
For this, there is an entry called Tags on the sidebar. Clicking on this will list all the available tags that you have created.
Now, clicking on individual tag entries here will display the contents of that particular tag.
Even more simple is that the tags are placed as a list on the sidebar itself. You can click on the entries to go to that particular list.
Searching for files with specific tags
You can search by file names in Dolphin. That’s not new. But you may refine the search based on tags as well.
For this, first press the search button on top right side.
You will get a view for entering your search term. Here you can search in the current directory or in all files.
Click on the dropdown on right as shown and select tags. Here you can filter your search by selecting the target tags.
Sorting items according to tags
In dolphin, you can start a sort operation based on tags (alphabetical or reverse). Also, you can sort the folders before files are mixed.
To do this, click on the hamburger menu and select sort by.
Here, you can select the Tags check box to sort. As shown in the above screenshot, you can specify the criteria also for the sorting.
Changing emblems of tags
This is purely cosmetic and for those who have OCD about organizing files. You can change the emblem (icon) of a tag to be visually more distinguishable.
In the above screenshots, you may have noticed that each tag appearing in the sidebar has different emblems. Right click on the name of the tag in sidebar and select edit.
You can press the image button in the new dialog box to change the icon as shown below.
Note that the emblems will appear only on the sidebar.
Removing tags
Don’t need a tag anymore? You can easily remove it.
Note that removing tags does NOT remove the files associated with them.
To remove an existing tag, you can go to all tags in the sidebar. Right click on a tag and press delete.
That particular tag will be removed automatically from all the associated files/folders.
Buggy feature: Copy a tag as a directory
On the All tags page, you can right-click and copy a particular tag and paste it to a location you like. This will paste all the entries with that particular tag into a separate folder.
You should keep in mind that while copying, there will be some warning messages about missing files. You can skip them. Those warning messages are shown because a directory under the tag you copied may contain other files/directories, which essentially are not part of the tag you are copying.
Here, some files inside the Folders-One directory are not part of the tag Tagger. So those files will not be copied.
Also, another glitch that I found was if the copied tag contains files, the same files will be duplicated inside the tag.
It is an issue only if you are copying the tag within your system directories and will not be an issue if you are copying a tag to an outside storage like an external hard disk or USB device.
Wrapping Up
Tags are indeed a great way to organize files, be they images or documents. Tagging feature can improve your productivity by enforcing neatness and order to your file storage and retrieval.
It’s good to see KDE providing this as a built-in feature. I guess this is one of the many differences between KDE and GNOME.
I feel I bit a bit more in detail as I wanted to give you all the required details. I hope you find it useful.
If you know any other cool KDE features you love, do share them in the comments.