Created
October 18, 2024 15:05
-
-
Save rsarrazin2/6fad352e3e85003ee0b7c55d5eea11d6 to your computer and use it in GitHub Desktop.
Batch file to collect lines from a file into a space-separated list stored into a variable exported to the call site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Required to expand the list at every for step | |
setlocal enabledelayedexpansion | |
rem Reference: https://stackoverflow.com/a/33824457/1945549 | |
set "list=" | |
for /f "delims=" %%i in (%~dp0\local_file) do set list=!list! %%i | |
rem Pattern required to export variable to the call site | |
endlocal & set list=%list% | |
rem Just for debugging, not required | |
echo %list% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment