1

I need to create a variable string like below, for passing as an argument to a software.

"filename:file1.txt|file2.txt|file3.txt"

I know I need to use a FOR loop in this way

FOR %%i in (*.txt) DO

But I am not aware how to save the information in the same variable. I prefer, if it is possible not to pass the details in a external file.

Mathews Jose
  • 399
  • 6
  • 18
Jacky12
  • 11
  • 3

1 Answers1

1

to append a string to a variable: set var=%var%new
You need delayed expansion to do this in a loop:

setlocal enabledelayedexpansion
set "list="
FOR %%i in (*.txt) DO set "list=!list!|%%i"
rem remove the first pipe symbol:
set list="%list:~1%"
echo %list%
Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91