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

Gnupg

Gnupg Problem Overview


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?

Gnupg Solutions


Solution 1 - Gnupg

Adding --batch --yes

Example:

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

Complete example with passphrase file:

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

Solution 2 - Gnupg

Just add the --yes option to you command line. The --yes option assumes yes for most questions which gpg will prompt for.

Source: http://www.gnupg.org/gph/de/manual/r1023.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRiderView Question on Stackoverflow
Solution 1 - GnupgTanya K.View Answer on Stackoverflow
Solution 2 - GnupgDavid MillsView Answer on Stackoverflow