Cmd line to Output decrypted *.CSV file with same name as the decrypted PGP file

Please help if you can, I have been searching the threads for two days…

I have written a script to decrypt my file and out the decrypted file to a folder.

My problem is keeping the same name as the decrypted file. In order for my script to work I have to tell it what to name the file. I just want to keep the same name as the encrypted file name.

The PGP files I receive has a name format the includes a date, we need to keep that name for the CSV file. I plan to automate the script to run each morning.

Encrypted file name: abc123.pgp
Decrypted file name: abc123.csv

here is my script: Like I said it is working fine, I just can’t keep that same file name.

gpg2.exe --batch --passphrase “SECRETPHRASE” --output “C:\SAME_AS_PGP_FILE_NAME.csv” -d “C:\abc123.pgp”

How do you get the encrypted file name? As in do you read the file directory and put the name into a variable? I call gpg2.exe from a batch file and pass the file name in as parameter. So inside batch job it would have:

gpg2.exe --batch --passphrase “SECRETPHRASE” --output “C:%1.csv” -d “C:%1.pgp”

Where %1 is the first value after the batch job name as in MyDecrypt.bat “abc123”. I use Toad Data Point to automate steps where I pipe the directory results to a file and then parse it to capture the file name(s) and store those in Toad variable and then call the batch job MyDecrypt.bat “#FilePath#” “#FileName#” FilePath is my %1 parameter and FileName is my %2 parameter (allows me to send different files to different locations with the same batch job). Then output would be --output “%1%2.csv”