vendredi 15 janvier 2021

In a batch file a variable is not shown correctly within an IF statement [duplicate]

after wasting many hours, now the question in the round: The following script does not give me what I expect. I have a path variable in which I delete the " characters and store the result in a new variable. But an echo output shows that this variable is empty, which is not true. The great thing is that without an IF query, everything works as I expect.

I am curious about your answers!

Greetings Christian

@echo off  
SET mypath="C:\temp"  
if exist %mypath% (  
    echo original = %mypath%  
    REM remove the " in mypath  
    set mypath3=%mypath:"=%  
    echo mypath = %mypath%  
    echo mypath3 = %mypath3%  
    set mypath3  
)  

Aucun commentaire:

Enregistrer un commentaire