How to automatically overwrite the output file when running `gpg` (i.e. without being prompted)?

Rider picture Rider · Sep 22, 2011 · Viewed 32.8k times · Source

If I have the same filename in the target directory, decryption fails.

The command I'm using to decrypt:

gpg --passphrase-fd 0 -o D:/Notification/mytest.txt --batch \
  --passphrase-file D:/passphrase.txt -d D:/Notification/mytest.gpg

It doesn't overwrite the mytest.txt file so each time I need to delete the file before I execute the script.

Is there any option to overwrite the output fie?

Answer

Tanya K. picture Tanya K. · Mar 14, 2012

Adding --batch --yes

Example:

gpg --batch --yes -u [email protected] -r "[email protected]" \
  --output "OUTPUTFILENAME.xls.pgp" -a -s -e "FILE.xls"

Complete example with passphrase file:

gpg --batch --yes --passphrase-fd 0 -u [email protected] -r "[email protected]" \
  --output "OUTPUTFILENAME.xls.pgp" -a -s -e "FILE.xls"< \
  passphrase.txt