Reputation: 119
I've been going around in circles for over an hour now, anyone tell me why this isn't working please?
I need to create an array of folders and with that array fire off a robocopy command
@echo off
setlocal EnableDelayedExpansion
set str=%USERPROFILE%
set server=\\poppy
call set mod=%%str:C:=%server%%%
if not exist "%mod%" mkdir %mod%
set list= %mod%\Documents %mod%\Downloads
set counter=0
(for %%a in (%list%) do (
echo.%%a
set counter=counter+1
echo.%counter%
))
pause
No matter what i try i can't increment the counter :-(
Upvotes: 1
Views: 470
Reputation: 57242
@echo off
setlocal EnableDelayedExpansion
set "str=%USERPROFILE%"
set "server=\\poppy"
call set "mod=%%str:C:=%server%%%"
if not exist "%mod%" mkdir %mod%
set "list= %mod%\Documents %mod%\Downloads"
set counter=0
setlocal enableDelayedExpansion
(for %%a in (%list%) do (
echo.%%a
set /a counter=counter+1
echo.!counter!
))
endlocal
pause
For more information check this - http://blogs.msdn.com/b/oldnewthing/archive/2006/08/23/714650.aspx
For arithmetical with SET
you need /A
switch.
Upvotes: 4