My question regards encrypting multiple files using a batch file using command line.
Previously (previous versions?) I was able to use the following code to encrypt ANY files located in a directory…
gpg -r sample@test.com --multifile --encrypt D:\Pathtodirectory/.
However now I have downloaded a newer version (only difference)
and it seems there is no --multifile but now is --encrypt-files
So my new command would be:
gpg -r sample@test.com --multifile --encrypt-files D:\Pathtodirectory/.
I have also tried:
gpg -r sample@test.com --multifile --encrypt-files D:\Pathtodirectory/*.txt
Always comes back with this error:
gpg: can’t open `C:\Users\name~1\Deskto~1\test\*.txt’: Invalid argument
Is there something I am doing wrong?
Operating system is windows xp and windows 7
I noticed the same thing. Does anyone know if the wild cards not working on gpg4win 2.1.1 was intentional or if later versions will have that included?
If I want to encrypt a whole directory of files, I generally use GpgEX since it was reinstated for Win7 64-bit. I select the sub-directory concerned, say \testfiles, right click and select ‘sign and encrypt’ and take it from there. Gpg4win then encrypts all the files and saves them in an encrypted file, in this case, called testfiles.tar.gpg. Being a tar, the file size is smaller too.
GpgEX decrypt works in reverse.
That seems easier than using the command line. If I use the command line for a smaller number of files, then I use something like :
Yes I understand how to decrypt/encrypt via the right click way,
My issue currently was,
In 2.0.1 the command line way allowed the encrypting of wildcard .txt files.
So I was able to create a batch file to search through folders and encrypt all *.txt - No way to encrypt folders with that version.
Now with newer versions the wildcard does not work, and now folders ARE allowed to be encrypted, So I was wanting to test this out via the command line and try to encrypt all folders inside a specified directory. Hopefully each creating their own gpg file. But I did not see a command line way of encrypting folders. From your answer it looks like there is not a command line method.
Anyone else figure a way to encrypt using wildcards in newer versions?
Or if there is a way ( that I do not see ) to encrypt folders via command line?
about the “invalid argument”, could it be that there is some strange file in this directory? Maybe a link or something protected? I am wondering because of the C:\ output while you are asking for a D:¸ file. Just an idea. You could try on a different directory.
There is nothing special in the directory. I currently use 2.0.1 release because that works fine with the wildcards (even on windows 7)
I am currently working on windows 7 and would think if 2.0.1 works why would 2.2.1 be any different? But I will try on an xp machine and see what happens.
Although extremely clumsy, the following workaround did the trick for me:
Step 1: Right-click the command prompt title bar and select “Properties”. Make sure the “QuickEdit Mode” box is checked.
Step 2: In the command prompt, navigate to the folder containing the files you want to encrypt.
Step 3: Type, “dir /oe” to get the contents of the folder ordered alphabetically by extension.
Step 4: Left-click, hold and drag to highlight the names (with extensions, of course) of the group of files you want to encrypt. (Note: The selection box doesn’t work quite like selecting text in Windows so make sure it’s all highlighted.)
Step 5: Right-click inside the command prompt window to copy the file names to the clipboard.
Step 6: Type the following at the new prompt: “gpg -r [Key ID] --multifile --encrypt-files” Hit [Enter] without typing anything else. The cursor should drop down to the next line with no prompt and just blink.
Step 7: Right click inside the window once more to paste all of the file names at the cursor location. All but the last file will be immediately encrypted. For the last one, you will have to hit [Enter] and then [Ctrl]+[Z], [Enter] to end the operation.
…And that’s it! Lol.
Also, I should point out that this seems to work with or without the “–multifile” command. However, it does not seem to work with “-e” (with or without add’l switches) or “–encrypt” (without the “-files” ending) alone. Using these results in encryption of the file names themselves, not the files. The exception is using “–multifile” with --encrypt" which seems to result in the behavior outlined in the steps above.
If nothing else, maybe this will be useful in figuring out what’s going on. IDK.
Yes, I get similar errors when trying to use wildcards:
“gpg: can’t open C:\\Users\\Owner\\Documents\\New folder\\*.txt': System error w/o errno gpg: encryption of C:\Users\Owner\Documents\New folder\*.txt’ failed: System error w/o errno”
I am running Windows 7 Home Premium 64-bit SP1. Gpg4win 2.2.0.
Thank you Sean for that short tutorial - as you said on another post, you can learn a lot on this forum. I never knew that a right click in the command prompt window would copy stuff to the clipboard - nor that another right click would paste it back.
One thing to be careful of - you need to be sure that the clipboard doesn’t get loaded with other stuff after the first right click.
I think I understood before that --encrypt-files is a more recent replacement of --multifile. I think however that I disagree with you about -e and --encrypt. I find that the procedure : “gpg -r userID --multifile -e” hit return and then right click - works ok
And it also works if the -e is replaced with --encrypt
(it doesn’t matter in which order is -e & --multifile )
In short: On windows the applications itself need to take care of the wildcards and when Gpg4win changed the compiler, it could have happened that something changed in this regard.
Can you please check If this works with the current Beta of 2.2.2. I have added a fix in there but I am not sure if it is a particularity of my testsystem that makes it work.