66

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?

Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
Rider
  • 863
  • 1
  • 11
  • 16

2 Answers2

113

Adding --batch --yes

Example:

gpg --batch --yes -u me@bbb.com -r "you@aaa.com" \
  --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 "you@aaa.com" \
  --output "OUTPUTFILENAME.xls.pgp" -a -s -e "FILE.xls"< \
  passphrase.txt
Kenster
  • 23,465
  • 21
  • 80
  • 106
Tanya K.
  • 1,146
  • 1
  • 8
  • 3
40

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

David Mills
  • 491
  • 3
  • 7
  • 15
    Isn't that dangerous, in that it will answer "yes" to questions other than "file exists - overwrite?" – OJW Dec 30 '12 at 14:15
  • Agreed! gpg asks you if you have not signed the recipients keys, and you will be saying "yes", right? – Edd Barrett Nov 29 '17 at 16:10
  • 6
    `rm -f filename.gpg && gpg2 [...] -o filename.gpg filename` may be appropriate in most cases. – AndiDog Mar 22 '18 at 15:43