Is there any program that can tag folders? I have different files within a folder and there are to many folders, if I could tag each folder (contrary to tag each file) then it would be very easy for me to categorise these folders. Does anyone knows if such thing can be done? Thank you.

  • What kind of tags are you looking for here? Extra meta tags of some sort, or will adding to the actual folder names work? Are you using the terminal to view files, or nautilus, or something else? – belacqua Mar 23 '11 at 4:14
  • Right click on one directory or file -> property -> click on Emblems tab select the emblems you want also you can add a note writing your not on note tab. if you are asking this way. – Achu Mar 23 '11 at 5:58
  • @Achu Thanks but I'm not looking for emblems, I've used them but they're only for a personal use, not to categorise data. – user12843 Mar 23 '11 at 6:10
  • @jbelacqua I'm using nautilus to view my files, this folders won't be added any other file but it contains different files, and what I want is to be able to rearrange my folders in such way that if I run a tag search, the specified folder or folders will show up, thus narrowing my results. The tags would be something like year, quality, language, etc. – user12843 Mar 23 '11 at 6:15
  • > Have you seen this Question? Tag and manage video files askubuntu.com/questions/29513/tag-and-manage-video-files .. .It does focus on individual files, but it seems that Banshee does a lot of the work you, and maybe it does soemthing with directories: – Peter.O Mar 27 '11 at 4:36

You may add a file like


into every folder. There you could store information as text. You could later browse them for your information.

Maybe you're better suited with a tool like find.

Feel free to ask about it's usage.

  • (+1) I like your idea so much I've used it instead of my Nautilus Notes suggestion.. The working script is shown in my answer.... To anyone reading this who likes the script, please remember that the .tag idea is 'user unknown's... – Peter.O Mar 24 '11 at 5:24

It is a great question, and I was looking for something like that too, but I'm pretty sure there is nothing like that already built into Nautilus,

but if you can turn your hand to some scripting, you could relatively easily adapt Nautilus file Notes to do something similar. It would require some basic(+?) scripting..

With file Notes you can add Notes to a Directory as well as files..

It would be a simple matter of searching the Notes for your specific Tag(s), and then create tempory links (or permanent) to each directory with a matching Tag in the 'Notes`... then put these links into a 'search results' directory... which you would then present in a Nautilus window!...

If I had the spare time, I'd do it myself, but instead, here is a script I wrote to access and write and delete Nautilus Notes.. It doesn't do what I described above, but it does show how to access the Notes data cache. The script is intended for use by nautilus-actions

The script is at pastbin.ubuntu.com

UPDATE: I've now written a working script which uses links as described above.. However, I've now swapped the "nautilus Notes" idea and grafted in user unknown's .tag files instead.. (so, if you like the script, remember that the .tag idea is 'user unknown's)..
I like plain text files (they are simple and versatile and very easy to work with)
I've used locate as the search tool, as it is ultra fast, but it is only as up-to-date as the last running of updatedb(which is typically daily, but you can run it any time).

I've attempted to explain the script's usage in the comments, but I should point out that it's not fully tested, so it may misbehave on some minor points..
The only things it deletes/removes are the temp directory and any soft-links it contains... Note that removing soft-links does not remove the target/data directories.

Here is the script

UPDATE2: (fixed a bug.. It was only processing the first 100 located .tag file)


# Script: dirtags ...(by fred.bear)
# Summary: Open the file browser in a temporary directory
#          which contains soft-links to directories whose     
#          '.tag' file contains the search string in $1
# .tag files are files you create in any directory which 
#      you wish to *tag*.
# .tag files are simple free form text, so you can 
#      put anything you like in them...  
# The script uses `locate` to create a list of .tag file
# 'locate' is very fast, but because it depends on 'updatedb'  
# for its list of current files, it can be a bit out of sync 
# with a newly added .tag file... Modifying an existing
# .tag file does not effect `locate`
# To refresh the `locate` database, just run 'sudo updatedb'
#  .. (updatedb typically auto-runs once a day, but you should check)
# Note: The search result soft links are put into a temporary directory
#   This directory is removed each time you run the script 
#   TODO: allow saved searches (?) maybe
# Note: With nautilus, running the script a second time while 
#   the previoulsy opened wiondow is still open, cause the 
#   second window to open in its parent directory: /tmp/$USER
#   ... but you can then just enter the 'dirtags' dir 
#       you see listed /tmp/$USER/$bname 
#       TODO: this probably happens because currently the
#         directory is being removed each time the script
#         is run...  (related to "allow saved searches")                    
# A sample usage of this script:
#   1.  Make a  '.tag' file in each of several test directories.
#   2,  For this first-time test, run 'sudo updatedb' so that the   
#       newly added  .tag files are added to the 'locate's database
#   3.  In each .tag file, put some tags (words or phrases to serch for)
#          eg; action comedy drama good bad sci-fi  documentary 
#   4.  Run this script with a single argument.. (a grep regex) 
#          eg "action|comedy" 

function args_grep_links {
  # $1 -- the grep regex
##echo grep -l '"'$1'"' ${tagged[@]}
  < <(eval grep -l '$1' ${tagged[@]}) \
      sed "s/^\(.*\)\/\.tag/ln -s \"\1\" $tagdbs/" \
##(gedit "$tagdir"/.tag.slinks &)
  # make the soft links
  source "$tagdir"/.tag.slinks
  rm     "$tagdir"/.tag.slinks
  unset tagged

# Identity the script
  bname="$(basename "$0")"
# Syntax
 if [[ "$1" == "" ]] ; then
  echo "ERROR: $bname requires one arg; a 'grep' regular expression string"
  echo "   eg: $bname \"music\" ......... Any instance of \"music\" .....(eg: \"musical\")"     
  echo "   eg: $bname \"\<music\>\" ..... Only the word \"music\" ...(but not \"musical\")"    
  echo "   eg: $bname \"muscic\|action\". Any instance of \"music\" or \"action\")"
  exit 1
# 'locate' the .tag files
# =======================
  [[   -d "$tagdir" ]] && rm -rf   "$tagdir" # remove all
  [[ ! -d "$tagdir" ]] && mkdir -p "$tagdir" # fresh start
  cp /dev/null "$tagdir"/.tag.slinks
  unset tagged  # array of .tag files 
  aix=0    # arg index
  amax=10  # arg max per call to grep 
  fct=0    # file count

  while IFS= read -r file ; do
####echo ${tagged[aix]}
    (( aix == amax )) && args_grep_links "$1"
  done < <(locate -ber ^\.tag$ |sed "s/.*/\"&\"/")
  (( aix < amax )) && args_grep_links "$1"
  sleep 1 # to allow time for rm  to settle down after rm and adding links 
  xdg-open "$tagdir"

  • I find that quite interesting and I'm going to look at it. However it would be nice, perhaps not in nautilus but any other program that could help you have some graphical interface, in fact I was thinking more like the idea behind a blog where you select a tag and all related to it comes up. Just for you to picture it, I have over 800 movies, all of them with covers and subtitles, which make at least 3 files under each folder. If I could just run some kind of tag search for example "action" and get to see all the covers related to action, then it would be easier to select a movie :D – user12843 Mar 23 '11 at 16:05
  • @Fernando.. Sorry, I can't help you with those particular requirements. (It sounds like more than a simple script can handle)... maybe the scipt I just added can fill the gap somehow until you find what you're looking for. As it stands, it can be run via the commandline (or <Alt> F2) .. eg. dirtags adventure – Peter.O Mar 24 '11 at 5:34

tracker-utils will work for this.

How to search for files by tags?

The answer hasn't been accepted yet, but the examples I posted should give you an idea of how to work with this program. Tag additions work just fine on directories too, and I've tested it as well.

Directory Example

<sean@mymachine:~> tracker-tag -a projects src/ code/ projects/
<sean@mymachine:~> tracker-tag -s projects
Results: 3

Note that you'll need to start trackerd manually in order for the tracker-tag/* utils to work:

<sean@mymachine:~> /usr/lib/tracker/trackerd &

You can configure tracker with:

<sean@mymachine:~> tracker-preferences

I still don't have the tracker applet running (listed in ps, but not showing up in nautilus even after nautilus -q), but I don't really care. I don't use GUI tools for the most part; I prefer CLI since it's usually much faster than clicking on things.

I read one of your responses from an earlier post, and it looks like you're trying to add/search for tags in Nautilus, although you didn't list that as a primary criteria in your question. That's what the other person was doing, so perhaps this answer will be useless for you. That said, jumping to CLI occasionally isn't so bad if you get stuff done that you wouldn't normally be able to do in a GUI.

Your Answer

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