Rename files from multiple directories along with directory indicator

Hi,

Friends, i have a requirement where i need to rename my files residing in multiple sub directories and move them to one different directory along with some kind of directory indicator.
For eg:
test--is my parent directory and it has many files such as
a1.txt
a2.txt
a3.txt

test1--subdirectory
b1.txt
b2.txt

test2--subdirectory
c1.txt
c3.txt

now, i want all these files to be renamed in one directory say temp directory, along with directory name or some kind of indicator, so that the renamed file can reveal from which directory it was taken and after renaming i want to move those renamed files from temp directory back to original directories (from which files taken for processing)

**renaming process is handled by informatica etl tool, where i want to add some information in files names.
so here is the flow--
->move files into temp folder(add some indicator in file name)
->rename files in informatica
->move back renamed files from temp directory to original directory based upon the indicator provided in first step(also remove that extra indicator)

apologize for such a long post, tried to simplify as much i can, kindly let me know if require any other information..

TIA

since you want to put them back in original context, why not simply do an archive?

I'm lost - mayhap you oversimplified?

When doing the "rename files in informatica", what will be the resulting file name? Will it still hold the directory part?

How about using symbolic links in the "temp" directory?

here is another detailed eg:

test --is my parent directory and it has many files such as

a1.txt
a2.txt
a3.txt

test1 --subdirectory(under test)

b1.txt
b2.txt

test2 --subdirectory(under test1 or test)

c1.txt
c3.txt

Now. my final file name should be like this:

<filename>_<tablename>_<clientname>.txt

i can read files from one directory, rename the files and put in desired folder but i cannot take files from multiple directories or sub directories in one go in informatica, either have to make different mappings for each directory(not a reliable option in long run).
So i want to take all files and put in one folder say temp:

Temp :

a1.txt
a2.txt
a3.txt
b1.txt
b2.txt
c1.txt
c3.txt

Now, i can process files in informatica all together and rename them according to the logic i mentioned above, after renaming files will be like:

a1_<tablename>_<clientname>.txt
a2_<tablename>_<clientname>.txt
a3_<tablename>_<clientname>.txt
b1_<tablename>_<clientname>.txt
b2_<tablename>_<clientname>.txt
c1_<tablename>_<clientname>.txt
c3_<tablename>_<clientname>.txt

after this, i want to put these files back to there original directory from temp directory, like:
test --is my parent directory and it has many files such as

a1_<tablename>_<clientname>.txt
a2_<tablename>_<clientname>.txt
a3_<tablename>_<clientname>.txt

test1 --subdirectory(under test)

b1_<tablename>_<clientname>.txt
b2_<tablename>_<clientname>.txt

test2 --subdirectory(under test1 or test)

c1_<tablename>_<clientname>.txt
c3_<tablename>_<clientname>.txt

**there will be 1000 files and 100s of directories, so i don't want to manually keep record of each file from which directory it belongs to, so here i would require 2 unix scripts, one script will put all files in temp directory and 2nd scipt should separate those files back to original directory.

How about

find test -type f | awk '{T = $0; gsub ("/", ".", T); print " echo mv", $0, "temp/" T}' | sh
mv test/A3 temp/test.A3
mv test/test1/B2 temp/test.test1.B2
mv test/test1/B3 temp/test.test1.B3
mv test/test1/test3/D2 temp/test.test1.test3.D2
mv test/test1/test3/D1 temp/test.test1.test3.D1
mv test/test1/B1 temp/test.test1.B1
mv test/test2/C1 temp/test.test2.C1
mv test/test2/C2 temp/test.test2.C2
mv test/A1 temp/test.A1
mv test/A2 temp/test.A2

for the to- direction?

as i told i might be getting 1000 files in 100 sub directories, i cannot write manual path for each and every file.
So i would need generic script which will handle any amount of files residing in one directory or sub directory..

*what ever file name or dir name have given just for understanding purpose.