Reputation: 1275
I have a script that I've put together that should copy the list of files to a variable but the only thing I receive is the last file. In other words, when I echo the variable in my for loop, I see 20 or so files but only the last one gets copied to my variable. How can I get them all to copy correctly?
I am using Windows 7.
@echo off
setlocal enabledelayedexpansion enableextensions
for /r %%x in (*) do (
echo %%x
SET PATH_VALUE=%%x;%PATH_VALUE%
)
Upvotes: 0
Views: 3897
Reputation: 77657
One way is to use delayed expansion. You've enabled it – half the job done. Now you only want to use it. Replace the %
s around PATH_VALUE
with !
s and you are done:
@echo off
setlocal enabledelayedexpansion enableextensions
for /r %%x in (*) do (
echo %%x
SET PATH_VALUE=%%x;!PATH_VALUE!
)
Upvotes: 1