Batch: "%~1" works, but "%~*" is a syntax error.
How do I find the equivalent command?
Since %* its batch parameter is a wildcard reference to all the arguments not including %0, you can't use ~ on it, but you can for loop on all arguments and %%~ them, example:
for %%x in (%*) do (
echo %%~x
)
Also if you need to combine them into single argument you can use setlocal enabledelayedexpansion with this loop:
setlocal enabledelayedexpansion
set args=
for %%x in (%*) do (
set args=!args! %%~x
)
echo %args:~1%
explain:
!args! is another way to use variable when using setlocal enabledelayedexpansion%args:~1% remove first space.And here is example without setlocal enabledelayedexpansion, which does not eat ! symbols from arguments:
set args=
for %%x in (%*) do call :SETARGS %%x
GOTO :END
:SETARGS
set args=%args% %~1
:END
echo %args:~1%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With