1.

Solve : Differences between %var and %~var?

Answer»

Anyone know what the differences are between those for batch files. I've SEEN some examples where they are used but haven't been able to figure out EXACTLY what's going on as it seems different commands handle it differently (i.e. FOR). I'm trying to figure out a way for trimming out a portion of a string read in from a file using the for command. I'm just having trouble finding any documentation on the differences between %~var and %var, obviously there is a difference as running
Code: [Select] set str="cmd politic"
ECHO.%str%
for /f "useback tokens=*" %%a in ('%str%') do set str=%%~a
echo.%str% Works correctly in trimming " " out. THANKSI told you what the tilde ~ character did 4 days ago. It seems you don't read posts very carefully.

Quote from: Me, on 18 March

One of the variable modifiers you can use with FOR metavariables of the %%x type is the tilde ~ which removes enclosing quotes (if present).


Discussion

No Comment Found