Andy Davidson wrote:
Here is once approach I had in mind: I would like to 'flatten' the
directory
structure, allowing me to apply the changes in 'batch mode' and
then returning
all files to their original sub-directories. Is this somehow
possible to do?
Here you're going to need to write a script which will store the
original directory a file is in, in some kind of database - whether
it's a plain text file, or you write a script to archive the data in
some kind of RDBMS - the latter will be more complex, but will
enable you to do shift the data around with some flexibility should
you want to, in an easy to use interface, and it might even be
faster than trying to handle an enormous plain text file holding the
same thing.
An alternative comes to mind, leave the original in place but hard
link a new file to it. Run the operations on the new filename and
then delete it - thus changing the original 'in place'.
Eg, given :
-+- A -+- 1
| +- 2
| \- 3
+- B -+- 1
| +- 2
| \- 3
...
for dir in A B ... (or it could be "for dir in <pattern>")
do
for file in ${dir}/*
do
ln ${file} common/${dir}.`basename ${file}`
done
done
So in common you end up with A.1, A.2, A.3, B.1, B.2, B.3, ... and so
on. You'll need some quotes in there if there's any possibility of
spaces in file/directory names.
Once you have done whatever operation, simply delete all the files in
common and magically the original files, in their original
directories have changed.
Simon