Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

decrypt multiple OpenPGP files in a directory

Tags:

I have several hundred gpg encrypted files in a directory, of the format filename.xyz.gpg where "xyz" is some arbitrary extension. I need to decrypt all of the files to generate filename.xyz decrypted in such a way that I don't have to manually enter the password for each file.

I have tried the following for directory "Testing":

for file in 'ls Testing'; do (echo <password>|gpg --passphrase-fd 0 -d $file 
--output     $file.decrypted);

I just wind up with a command prompt >, and nothing happens.

What is the matter with my syntax? Is there some more efficient way to do this without a bash shell loop?

like image 978
user1815498 Avatar asked Sep 12 '13 16:09

user1815498


People also ask

How do I decrypt all files in a folder?

Right-click on the encrypted file and select Properties. In the General tab, select Advanced. Now, uncheck the Encrypt contents to secure data radio box and click on OK. You'll see another dialog box asking if you want to Apply changes to this folder or Apply changes to this folder, subfolders and files.

Can gpg decrypt PGP files?

GPG can open and decrypt files encrypted by PGP or Open PGP, meaning it works well with other products.


1 Answers

gpg can decrypt multiple files so you shouldn't need to write a loop.

Try the following. You will need to enter your password once.

gpg --passphrase-fd 0 --decrypt-files *.gpg 
like image 166
dogbane Avatar answered Sep 18 '22 16:09

dogbane