user441521
user441521

Reputation: 6998

DOS variable not echo'ing or concatenating

ECHO %filenameWithoutPGPExt%: this line doesn't show anything in the cmd prompt. It also doesn't concat in thegpg.exe line. Any ideas?

FOR %%F in (%inputDir%\\Invoices*.pgp) DO ( 
    SET fName=%%F
    SET filenameWithoutPGPExt=%%~nF

    ECHO %filenameWithoutPGPExt%

    C:\GnuPG\gpg.exe --batch --yes --output %outFilename%%filenameWithoutPGPExt% --passphrase-fd <C:\\GnuPG\\pasfraz.txt --decrypt %%F 
)

Upvotes: 0

Views: 38

Answers (1)

user7818749
user7818749

Reputation:

Give this a go. You can change D:\dir at inputdir variable.

@echo off
set "inputdir=D:\dir"
setlocal enabledelayedexpansion
FOR %%F in (%inputDir%\Invoices*.pgp) DO ( 
    SET "fName=%%F"
    SET "filenameWithoutPGPExt=%%~nF"
    ECHO !filenameWithoutPGPExt!
    C:\GnuPG\gpg.exe --batch --yes --output %outFilename%!filenameWithoutPGPExt! --passphrase-fd <C:\\GnuPG\\pasfraz.txt --decrypt %%F 
)

You also do not need to set a variable, unless used elsewhere aswell.. Below demonstrates that the values will remain the same as if you set a variable.

FOR %%F in (%inputDir%\Invoices*.pgp) DO ( 
    echo %%F
    echo %%~nF
)

Upvotes: 2

Related Questions