Shell script to decrypt and move files in a directory

So, I have a directory, and in it are several files.  I'm trying to decrypt those files and then move them to another directory.  I can't seem to figure out how to set the output filename and move it.

So, the directory structure looks like this:


For all of the files found in the encrypted directory, I'm trying to decrypt it and then move them into www/decrypted/.  I don't know what the filenames in the encrypted directory will be ahead of time (this script will eventually run via cron), so I wanted to just output the decrypted file with the same filename, but without the pgp.  So, the result would be:


So, this is all I have so far, and it doesn't work...  FILE and FILENAME are both wrong...  I haven't even gotten to the moving part of it yet.... Help?
pass_phrase=`cat passtext.txt|awk '{print $1}'`

for FILE in '/Applications/MAMP/bin/encrypted/';
    FILENAME=$(basename $FILE .pgp) 
    gpg --passphrase $pass_phrase --output $FILENAME --decrypt $FILE

Open in new window

Who is Participating?
tty2Connect With a Mentor Commented:
To drop .pgp extension use "${FILE%.pgp}":

gpg --passphrase $pass_phrase --output ${FILE%.pgp} --decrypt $FILE
n00b0101Author Commented:
Not really...  I need to drop the .pgp extension, not add it? And, I also don't see anything about decrypting it?
All Courses

From novice to tech pro — start learning today.