first, you can't do a "cd" inside a loop---each time thru the current directory will be different, so cd will be starting from a different reference point. to iterate through directories (or files) in a directory, just do something like:
Code:
for item in *; do
stuff
done
or:
Code:
for item in `ls|grep "something"`; do
stuff
done
Also, look at the man page for tar---eg when specifying the output file (f flag), the syntax to create an archive is eg "tar -cvf <newfilename> <path>"
Finally, if you want to create a bunch of archives, and the just extract certain ones, I wonder if it would be better to have 2 loops?