gpg - decrypt file without --output option


I want to decrypt files with gpg (GnuPG) 2.2.27 and password without the --output option, so that the output file is just without the .gpg ending. This works, if I omit the ( --decrypt) command, like this:

gpg --batch --passphrase 'password' myfile.txt.gpg

But it gives me the warning:

gpg: WARNING: no command supplied. Trying to guess what you mean ...

How can I decrypt without this warning, without adding an --output option and a path for the decrypted path?
I just want the decrypted file without the .gpg ending and not as stdout.

Thanks, frank

PS.: I am trying to create an Android Tasker encryption/decryption Task with the help of Termux, see: HowTo: Encryption of files or folders in Tasker with Termux gpg

Hi @francwalter,

you have to use -d or --decrypt to tell gpg that you want to decrypt a file.

Why is it important to you to decrypt a file without the --output option? If you’re using this option you don’t have to specify a path. You can just write --output myfile.txt so you get the file without the ending .gpg and it will be created where the gpg command is executed.

1 Like

OK, it is not possible I guess.
It’s working this way (without -d) I just wanted to make it cleaner code (without warning).

If I use the file name (with -o), then I would need to extract it first and could not use just a simple bash loop, that’s why. Would blow up the code.
Ok then thank!

Try this:

gpg --pinentry-mode=loopback --passphrase "abc" -q --batch --yes test.txt.gpg

And maybe look at the implications from this caveat for --batch from the man page:

It is highly recommended to use this option along with the options --status-fd and --with-colons for any unattended use of gpg.

1 Like

Ok, if I add the --quiet option (-q), the warning is omitted, but the --decryption command here is still missing.
In my case (in the loop) this warning is not showing up anyway. I only see it, if I decrypt a single file.
But I will add the --quiet option, to be sure :blush:

So I assume: it’s not possible to decrypt as default to a file name just without the .gpg, only if I omit the --decrypt command.

Yes. With --decrypt you’ll have to give the desired filename after --output. Same as if you use redirection with “>”.

I’m not sure if it is a good idea to leave off the --decrypt in your case, as the fallback to decryption could possibly be removed in the future. Though I don’t think it will. But I wouldn’t consider it a stable interface anyway…

1 Like