Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 678329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:08:15+00:00 2026-05-14T01:08:15+00:00

I have a directory and in it has several files. I’m trying to decrypt

  • 0

I have a directory and in it has several files. I’m trying to decrypt those files and move them to another directory. I can’t figure out how to set the output filename and move it.

So, the directory structure looks like the following:

/Applications/MAMP/bin/decryptandmove.sh
/Applications/MAMP/bin/passtext.txt
/Applications/MAMP/bin/encrypted/test1.txt.pgp
/Applications/MAMP/bin/encrypted/test2.txt.pgp
/Applications/MAMP/htdocs/www/decrypted/

For all the files that are found in the encrypted directory, I’m trying to decrypt them and then move them to the directory 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 job), so I wanted to just output the decrypted files with the same filenames, but without the pgp. So, the result would be:

/Applications/MAMP/bin/decryptandmove.sh
/Applications/MAMP/bin/passtext.txt
/Applications/MAMP/bin/encrypted/
/Applications/MAMP/htdocs/decrypted/test1.txt.pgp
/Applications/MAMP/htdocs/decrypted/test2.txt.pgp

So, this is all I have written so far and it doesn’t work. FILE and FILENAME are both wrong. I haven’t even gotten to the moving part.

pass_phrase=`cat passtext.txt|awk '{print $1}'`

for FILE in '/Applications/MAMP/bin/encrypted/';
 do
    FILENAME=$(basename $FILE .pgp) 
    gpg --passphrase $pass_phrase --output $FILENAME --decrypt $FILE
 done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:08:16+00:00Added an answer on May 14, 2026 at 1:08 am
    #!/bin/bash
    p=$(<passtext.txt)
    set -- $p
    pass_phrase=$1
    destination="/Applications/MAMP/htdocs/www/decrypted/"
    cd /Applications/MAMP/bin/encrypted
    for FILE in *.pgp;
    do
        FILENAME=${FILE%.pgp}
        gpg --passphrase "$pass_phrase" --output "$destination/$FILENAME" --decrypt "$FILE"
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a directory with several subdirectories with files. How can I copy all
I have a directory which contains several files, many of which has non-english name.
I have an NFS-mounted directory on a Linux machine that has hung. I've tried
I have a directory with PDF files that I need to create an index
I have a directory full of files and I need to pull the headers
I have a directory of files that I'd like to append file extension to
I have a directory with 500,000 files in it. I would like to access
I have a directory full (~10 3 , 10 4 ) of XML files
I have edited several files ISO-8859-15 encoded php source files with netbeans 6.7.1, but
I downloaded SWFObject & it came with several files it has one swfobject.js file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.