logo

How to receive multiple input parameters in a batch command 📂Programing

How to receive multiple input parameters in a batch command

Code

In batch command, for a natural number mm, %n refers to the nnth parameter, and the array of all parameters is represented as %*1. For example:

alt text

Let’s assume there is a batch file named multi.bat in the directory as shown above.

@echo off

echo %%1: %1
echo %%3: %3
echo %%*: %*
pause

drag_and_drop.webp

The result of executing multi.bat by drag-and-dropping the three folders A, B, and C is as follows:

alt text

Environment

  • Windows11
  • Linux Mint 21.2 Cinnamon v5.8.4