I'd like to find a Windows batch counterpart to Bash's $@
that holds a list of all arguments passed into a script.
Or I have to bother with shift
?
You can send any data types of argument to a function (string, number, list, dictionary etc.), and it will be treated as the same data type inside the function.
To extract the number and names of the arguments from a function or function[something] to return ("arg1", "arg2"), we use the inspect module. The given code is written as follows using inspect module to find the parameters inside the functions aMethod and foo.
args() function in R Language is used to get the required arguments by a function. It takes function name as arguments and returns the arguments that are required by that function.
In Python, Arguments in a function may be of any data types like list, string, dictionary etc., Inside the function also it is treated as the same data type. If we give List as an argument to the function, it will consider the argument as List even if it is inside the function.
dancavallaro has it right, %*
for all command line parameters (excluding the script name itself). You might also find these useful:
%0
- the command used to call the batch file (could be foo
, ..\foo
, c:\bats\foo.bat
, etc.)%1
is the first command line parameter,%2
is the second command line parameter,
and so on till %9
(and SHIFT
can be used for those after the 9th).
%~nx0
- the actual name of the batch file, regardless of calling method (some-batch.bat)%~dp0
- drive and path to the script (d:\scripts)%~dpnx0
- is the fully qualified path name of the script (d:\scripts\some-batch.bat)
More info examples at https://www.ss64.com/nt/syntax-args.html and https://www.robvanderwoude.com/parameters.html
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