How to strip quotes from the script arguments in batch files?

Viewed 2131

Suppose you're writing a Batch script in which you want to strip the quotes from a string.

If the string is stored in a regular Batch variable, you would do this:

set name="John"
echo %name:"=%

If the string is stored in a positional parameter, you would do this:

echo %~1

How would you go about achieving the same effect for script arguments, specifically the %* variable? When I try to use the same notation I use for positional paramters, I get this:

> echo echo %~* > script.cmd

> script "123" "456"
The following usage of the path operator in batch-parameter
substitution is invalid: %~* 


For valid formats type CALL /? or FOR /?
script was unexpected at this time.

How can I make this work? Is there any special syntax for this that I'm not aware of? Any help would be appreciated, thanks!

1 Answers
Related