No doubt a boring old school trick for the Powershell users among you, so, like, over batch files but handy in case of emergency:
If you supply a quoted parameter to a batch file (e.g. a directory path) and later need to remove the quotes to accommodate additional manipulation, handle the incoming parameter as %~1 instead of %1.
To remove a trailing slash, do this:
IF "%SOLUTION_DIR:~-1%"=="\" SET SOLUTION_DIR=%SOLUTION_DIR:~0,-1%
Just what I needed!
ReplyDeleteHad been trying to solve:
SET Ext=%1
...
IF "%Ext%" EQU "*" ECHO You passed a wildcard
kept giving me the output if I passed the asterisk double quoted:
IF ""*"" EQU "*" ECHO You passed a wildcard
Switched my line to:
SET Ext=%~1
and all works perfectly!
Thanks,
S.C.
Thank you!
ReplyDelete