# Associating a group of files [closed]

This would be like creating a project - I'd like to associate several different types of documents together, so that I can open one main document then click an option to get a list of documents within that project.

For example a report which associates two spreadsheets and three documents. Ideally opening one would open all of them, so that the whole report is available to work on and I can just swap windows from one to another.

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2015-10-18 04:09:06.283781

Sort by » oldest newest most voted

Thanks mjjzf and w_whalley for stimulating my thought processes. Here is the final script, I hope someone finds it useful:

#!/bin/bash
echo There are no guarantees on its actions.
echo For example it needs a limit on the number of files it opens.

project=$(basename "$0")
project=${project%.*} length=${#project}

for fn in *; do
ext=${fn#*.} file=${fn:0:length}

if [ "$file" = "$project" ] ; then
if [ "$ext" = "odt" -o "$ext" = "ods" ] ; then
echo "$fn" libreoffice "$fn" &
fi
fi

done


Check that all the files you want associated with the project and opened at the same time start with the same name and are .ods or .odt ones. Save the script into the directory with the same name, give it the executable property.

Double-click on the script to open all the files but no others, example:

club files.sh

club files.ods

club files.odt

club files document 1.odt

club files document 2.odt

more

I don't want to have to maintain a list of links. In fact if I just put all the files in the same directory there wouldn't be any need to, because that is an association in itself. What I need then is to open them all at once with one action.

What I need is a script which when run will open all files in a directory using their associated applications. I've just found this very good webpage which explains bash scripts

http://arachnoid.com/linux/shell_programming.html

and written this:

#!/bin/bash
for fn in *; do
if [ "${fn#*.}" = "odt" ] then libreoffice "$fn" &
fi

if [ "${fn#*.}" = "ods" ] then libreoffice "$fn" &
fi

done


Which does the trick.

more

Create a project directory and populate with your files and/or links to your files. To open them all in separate windows, move to the directory and run the command soffice *.odt *.ods (I only tested with these.) This command could be put in a script. Even shorter, soffice *.od?

( 2012-10-05 15:04:17 +0200 )edit

That's a much simpler solution than mine! I've also realised that I could select all the files in a file manager then double-click on them. Sometimes the simple and neat solutions are hard to see. I'm still working on a slightly more sophisticated Bash script and will post if if I get it to work.

( 2012-10-05 16:39:21 +0200 )edit

I have actually had something similar - back when I was first using Linux, I put a button on my taskbar which linked to a script which opened calendar, email and task app - which I would always use together.

( 2012-10-08 08:57:51 +0200 )edit

I'm not sure what you mean by embedding, do you mean putting a hyperlink into each document for each of the others?

Is so, it would be a work round, although perhaps a little clumsy, as adding a new file would require adding a link to it in each file.

more

I was just thinking you could have a main index document with links to the others.

( 2012-10-05 12:44:21 +0200 )edit

mjjzfI I've tried that in the past and it's not what I want - but your ideas are helping my thought process in working out what I do want!

( 2012-10-05 12:50:42 +0200 )edit

How about just linking or embedding them in, say, a Writer document?

more