Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

4 Answers

You may add a file like

.tag

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.

share|improve this answer
    
(+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
add comment

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)

#!/bin/bash

# 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/" \
    >>"$tagdir"/.tag.slinks
##(gedit "$tagdir"/.tag.slinks &)
  # make the soft links
  source "$tagdir"/.tag.slinks
  rm     "$tagdir"/.tag.slinks
  unset tagged
  aix=
}

# 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
 fi
# 'locate' the .tag files
# =======================
  tagdir="/tmp/$USER/$bname"
  tagdbs="${tagdir//\//\/}"
  [[   -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
    tagged[$aix]="$file"
####echo ${tagged[aix]}
    ((aix++));((fct++))
    (( 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"

exit
#
share|improve this answer
    
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
add comment

Wow fred bear, this is such a fantastic work you've got there! Can't wait to try it. I really appreciate your effort and even though the original idea is slightly different as mentioned before it still is an excellent approach to the behaviour I needed in the first place. And just after reading the explanation in the script it came to me the idea that if it is possible to generate some sort of html with soft-links to all of the resulting folders from the tag search from the temporary directory but showing only the covers (jpg's) as the icon to click to. I'm going to test the script and see how it behaves and if it creates soft-links to the folders, can them then be soft-linked to the video file but showing the jpg within the folder as icon? I want to thank you again for your effort and knowledge, I'm not good at scripts and would never have thought this sort of solution. Thank you.

share|improve this answer
    
:) thanks... I was thinking html was what you are after, but my ability to write a web/html style app doesn;t go much past the 'title' label.. (and I've probably got that wrong too ;) –  Peter.O Mar 24 '11 at 6:42
    
PS.. Once you've located the relevent diectories, you can then use locate again to list relevant images etc in those directories... and then make links to those files instead of making links to the directories.. It's just more of the same thing... –  Peter.O Mar 24 '11 at 7:39
    
...and I just noticed a bug! ... it was limited to the first 100 tags, I rushed... ("haste makes waste!") .. I've fixed it, and reposted it.. –  Peter.O Mar 24 '11 at 7:57
add comment

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
  /home/sean/projects
  /home/sean/src
  /home/sean/code

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.