Reputation: 75
I am trying to encrypt all TXT files in a specific folder using the wildcard *.txt. When I run the PowerShell code in Admin rights I get this error message.
set-alias sz "$env:C:\Program Files (x86)\GNU\GnuPG\gpg.exe"
sz --encrypt --recipient "AABB (2048-bit)" "C:\Users\AA\Desktop\AABB_Test\*.txt"
Error:
**sz : gpg: can't open `C:\Users\AA\Desktop\AABB_Test\*.txt': No such file or directory**
But If I choose just one of the txt file:
set-alias sz "$env:C:\Program Files (x86)\GNU\GnuPG\gpg.exe"
sz --encrypt --recipient "AABB (2048-bit)" "C:\Users\AA\Desktop\AABB_Test\1_test_file.txt"
It works fine.
Upvotes: 1
Views: 301
Reputation: 27423
In bash, the shell interprets the wildcard. In cmd or powershell, each command interprets the wildcard using a library.
Upvotes: 0
Reputation: 9591
The code below should produce the result you desire.
Set-Alias sz "$Env:SystemDrive\Program Files (x86)\GNU\GnuPG\gpg.exe"
$dirWithFiles = "$Env:SystemDrive\Users\AA\Desktop\AABB_Test"
Get-ChildItem -Path $dirWithFiles | ForEach-Object {
sz --encrypt --recipient "AABB (2048-bit)" "$($_.FullName)"
}
Upvotes: 2