[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cross-referencing files in a GUI



On Wednesday 19 July 2006 16:56, Ron Johnson wrote:
> John O'Hagan wrote:
> > Hi,
> >
> > I would like to be able to browse a set of files according to variable
> > criteria without being restricted to particular directories.
> >
> > A simple model to demonstrate: say I have three folders named "work",
> > "rest" and "play", each containing sub-folders called "pictures",
> > "music", and "text".
> >
> > What if I want to also view the same files as three folders
> > named "pictures", "music", and "text" each containing three sub-folders
> > named "work", "rest" and "play"?
> >
> > Or what if I want to browse my photos in folders according to date
> > ranges, then switch to a view where they are categorised in folders
> > according to whether they are portraits, landscapes, or buildings; or by
> > location, or the name of the subject, etc.?
> >
> > In either case it would be desirable to be able to apply the views over
> > an arbitrary number of directory levels, so that, for example a file does
> > not necessarily appear on the same level (or even the same number of
> > times) in every view.
> >
> > One way of conceptualising this could be as a number of co-existing
> > virtual directory trees, each corresponding to a particular view of the
> > same (or overlapping) sets of files. Perhaps using hard links? Or is
> > there a simpler way?
> >
> > Apart from the greater flexibility, this would eliminate the need for
> > duplicated subdirectories, i.e., each view would only be as complex as
> > necessary for a particular purpose, replacing one complex tree with
> > several simple ones.
> >
> > Is there anything like this available in Debian, or is there a neat way
> > to set it up?
>
> Beagle might be what you want.
>
> Or symlinks.

I've been doing some research on this, and Beagle is one of many projects 
which seem to be working towards the idea of a "semantic desktop", where 
a "heap" of files is viewed according to any number of metadata tags, either 
built-in or added by the user. A file can thus belong to any number 
of "folders", and the "tree" ceases to exist, at least as far as the user is 
concerned. Photo-management programs like digikam already do this: pictures 
can be viewed according to built-in or arbitrary tags to a point where it 
becomes irrelevant what folder they live in. I guess I'm looking for ways to 
extend this to all types of data, using a unified indexing engine and 
interface.

Some of these projects are: Beagle, GLScube, Strigi (for KDE), tracker, 
heap-buddy, and at the filesystem level, lufs, fuse and union-fs.

If anyone is up-to-date on this stuff, I'd be interested to hear about it.

About my initial post where I wanted to be able to rearrange directory trees 
according to various criteria: I've written a short bash script to 
demonstrate this. It creates a folder in ~/ and puts folders in it containing 
hard links to all files from all folders of a given name. You can keep the 
rest of the original directory structure leading down to those files or not. 
It uses the small utility mmv to do the linking. 

I've included it below in case anyone wants to try it. It can't handle 
directory names with spaces, it simply overwrites links to like-named files 
(not the original files!) when the single-directory option is used, and mmv 
generates a lot of screen garbage.

I'd appreciate any comments or suggestions. 

John.


#!/bin/bash

scriptname=altview

usage="\n	Usage: $scriptname [ -a ] DIRECTORY1 [ DIRECTORY2 
DIRECTORY3 ...]\n\n	Only use the basename of DIRECTORY (not the full path, 
case insensitive).\n\n	$scriptname -r\n\n	$scriptname -h for help.\n"

help="$usage\n	$scriptname creates a new directory tree under ~/$scriptname 
with DIRECTORY as the root.\n	containing hard links to all the files in any 
folder named DIRECTORY.\n\n	This means you can view the contents of all 
subfolders of the same name\n	as a single tree containing only those files.
\n\n	By default, all the original subdirectories are reproduced,\n	but the -a 
option puts all the linked files in DIRECTORY.\n\n	The -r option refreshes 
any existing trees in ~/$scriptname\n"

[[ $* ]] || echo -e "$usage"
[[ $1 == '-h' ]] && echo -e "$help" && exit


#For refresh option: set arguments to existing directories

if [[ $1 == -r ]]; then

	existing=$(ls -a ~/$scriptname | grep [a-z,0-9])
 	[[ $existing ]] && set $(echo $existing) || exit
fi


#Get list of folders

contents=$(ls -aR1 | grep / | grep -v $scriptname/ | sed s/://g | sed s/.//)


for i in $*; do 

	#Do not process -a option as a folder!

	[[ $i == "-a" ]] && continue 


	#Get paths for each folder entered 

	paths=$(echo "$contents" | grep -iw "$i")
	[[ $paths  ]] || echo "$i: no such folder"

	for j in $paths; do

		#Rearrange the path to put the entered folder at the top

		if [[ $1 == "-a" ]]; then

			newpath=~/$scriptname/"$i"

		else newpath=~/$scriptname/"$i"$(echo "$j" | sed s/"\/$i"//g)
		fi
		
		#Create new folders in ~/$scriptname

		mkdir -p  $newpath

		
		#Link the files 

		mln -d ".$j/*" $newpath  
	done
done	



Reply to: