problem with output re director to a file

I have a file named XXX_TEF_20120530234576.txt.pgp

I am creating a new file with the below syntax but looks it doesnt like the redirection

for file in XXX_TEF_20120530234576.txt.pgp ;do;
echo $file
cat $file | /usr/bin/gpg/ -d > echo $file | cut -f1,2 -d'.'
done;

What I want actually is the o.p written to a txt file derived from the file name

basically something like thid

for file in XXX_TEF_20120530234576.txt.pgp ;do;
echo $file
cat $file | /usr/bin/gpg/ -d > XXX_TEF_20120530234576.txt
done;

can somebody tell me what's wrong with my script?

you can use -o option with gpg command to write into o/p file.

Tks. But i have many files in there and I need to derive it with the cut and echo command for each file o\p

use below code for output file

$(basename $file ".pgp")

Ex.

$>basename XXX_TEF_20120530234576.txt.pgp ".pgp"
XXX_TEF_20120530234576.txt

this is truncating the directory path it needs to write to. I don't know where the file is being written to

---------- Post updated at 01:51 PM ---------- Previous update was at 01:40 PM ----------

never mind. Tks for the help. got it working now.

$>file=/root/XXX_TEF_20120530234576.txt.pgp
$>echo ${file:0:(${#file}-4)}
/root/XXX_TEF_20120530234576.txt

OR

$>echo $(dirname $file)"/"$(basename $file ".pgp")
/root/XXX_TEF_20120530234576.txt

tks pravin27. I have one quick question.

After I get the decrypted files i need to encrypt them. I need to attach .pgp at the end of the filenames i just derived. How can I do that.