Variable Assignment for arguments with a for loop

Posted by RainbowDashDC on Super User See other posts from Super User or by RainbowDashDC
Published on 2013-06-27T01:22:44Z Indexed on 2013/06/27 4:24 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

Alright, so, I've searched quite a bit on how to do this but I've given up as I simply couldn't find anything.

So, I have a code (below); it's main purpose is to get 9 arguments and assign them as a variable-- ignore the echo's and pipping.

My question is: How can I simplfy this with a for loop or such so it doesn't take as much code, and if possible, have more than 9 arguments aswell

set pkg1=%1
set pkg2=%2
set pkg3=%3
set pkg4=%4
set pkg5=%5
set pkg6=%6
set pkg7=%7
set pkg8=%8
set pkg9=%9

IF DEFINED pkg1 (echo %1.ini 1> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg2 (echo %2.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg3 (echo %3.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg4 (echo %4.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg5 (echo %5.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg6 (echo %6.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg7 (echo %7.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg8 (echo %8.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)
IF DEFINED pkg9 (echo %9.ini 1>> %WINGET_TEMP%\args.rdc 2>nul)

© Super User or respective owner

Related posts about command-line

Related posts about batch