Running Ubuntu Gnome.
I have a lot of PDF and other documents and I will like to tag them. And search them later based on these tags. Even if I move the files to different folders (so, the tags stick to the files).
I searched but Files and Documents do not provide this options.
Am I doing something wrong? How can I tag files so I can search them based on tags later?
Contents:
1. Introduction
This solution consists of two scripts - one for tagging, one for reading the list of files under specific tag. Both have to live in
~/.local/share/nautilus/scripts
and activated via right-click in Nautilus file manager on any file, and navigating to Scripts submenu. The source code for each script is provided here as well as on GitHub2. Installation
Both scripts have to be saved to
~/.local/share/nautilus/scripts
, where~
is user's home directory, and made executable withchmod +x filename
. For easy installation, use the following bash script:3. Usage:
Tagging files:
Select files in Nautilus file manager, right click on them, and navigate to Scripts submenu. Select
tag_file.py
. Hit Enter First time you run this script, there will be no configuration file, so you will see this:Next time, when you already have some files tagged, you will see a popup that allows you to select a tag and/or add new one ( this way you can record files under multiple tags). Hit OK to add files to this tag. Note:Avoid having "|" symbol in the tag name.
The script records everything in
~/.tagged_files
. That file is essentially ajson
dictionary ( which is not something regular users should care about, but it's convenient for programmers :) ). The format of that file is as so:If you ever want to "untag" some file, just delete an entry from that list. Mind the format and commas.
Searching by tag:
Now that you have a nice
~/.tagged_files
database of files, you can either read that file, or useread_tags.py
script.Right click on any file in Nautilus ( really doesn't matter which ).Select
read_tags.py
. Hit EnterYou will see a popup asking you what tag you want to search:
Select one, click OK. You will see a list dialog showing you want files are there for the tag you selected. You can select any single file and it will open with a default program assigned to that file type.
4. Source code:
tag_file.py
:read_tags.py
:I have found a way to do this.
Open a terminal (CTRL+ALT+T) and then run this command:
sudo add-apt-repository ppa:tracker-team/tracker
Enter your password, and when Prompted, press enter, then run
sudo apt-get update
then
sudo apt-get install tracker tracker-gui
Don't worry if it says it's already the latest version.
Now open Nautilus/Files and right click the document you want to add tags to. Select properties, then select the tab that says "Tags". Enter a tag into the text box and press enter or click the Add button to add it. You can also click a tag you have already added and select the Remove button to remove a tag. Please note that tags are case sensitive. The tags you create will be persistent throughout the system, so you can easily put a check next to a tag you already created to mark the file instead of manually typig it again.
After tagging the items wanted, you can now search for them, but not in Files. Go to activities, and search for the app
Desktop Search
. Launch it, and look at the options at the top. At the top left side of the Window, click the folder icon with the tool tip "Display results by files in a list". Now you have more options. Select the option just to the left of the search box with the tool tip "Find search criteria in file tags only". Now you can search tags!To use this, enter the tags you want to search, seperated by commas and press enter. For example:
Important, September, Presentation
This will only show files which have all three tags: "Important", "September", and "Presentation".
By double clicking one, it will open the file in the default program, and by right clicking and selecting "Show Parent Directory", it will open it's location in Nautilus.
In Desktop Search, you can also click the second button from the right at the top of the window (usually a star or heart) to edit tags in the app itself!
There you have it! Hope this helps. If you have any more questions, let me know.
Short answer: This is not possible natively in Ubuntu. You need some extension or a document database, as suggested by the other answers.
Another option I can recommend is to use the app TagSpaces. This app may save tags in the filename, which makes tagging durable and portable. You may edit the filename in Nautilus or within your Cloud-Storage and the tag will appear in TagSpaces and vice versa.