I've a list of users in a text file (users.txt) and I want, for each user, to copy every file in their directory (c:\Folder\username) and subdirectory in another directory without subdirectory (c:\Folder 2\username).
I'm now using a batch file containing something like this:
for /f %%u in (user.txt) do (
for /r "C:\Folder\%%u" %%f in (*.*) do @xcopy "%%f" "C:\Folder 2\%%u"
)
...but is not working.
After some tests I was able to find out what's wrong: the first %%u variable in the second FOR
for /r "C:\Folder\%%u" %%f in (*.*) do @xcopy "%%f" "C:\Folder 2\%%u"
is not correctly replaced by the username.
Instead the second %%u (inside the DO command) is correctly replaced by it's value.
Is there a way to force the first %%u variable to take the correct value?