I'm trying to fill a variable with a space-separated list of files, but I can't quite seem to get my head around it.
Here's what I have so far:
set js_files= for %%f in (js/*.js) do set js_files=%js_files% js/%%f echo %js_files% C:\path\to\jsminifier.exe --inputfiles %js_files%
I would have expected this to keep appending the
js_files variable with the next filename, but instead it replaces the whole variable:
c:\dir>script.cmd c:\dir>set js_files= c:\dir>for %f in (js/*.js) do set js_files= js/%f c:\dir>set js_files= js/one.js c:\dir>set js_files= js/two.js c:\dir>set js_files= js/three.js c:\dir>echo js/three.js js/three.js
I see in the second line of output that the whole
for line seems to be parsed before execution, so the (initial) empty variable value is used for all iterations.
Does anyone know how to properly append to the variable?