I am a newbi and apologize if I am not asking the question correctly, but I want to loop through a list, assigning a variable to specific tokens in that list, then pass the variables to a command (using both variables for each variable 1??? Not sure if I am asking the question properly.
The WK1List1 has something like this:
servername ipaddress
anotherservername anotheripaddress
-- batch segment is --
::format date in yyyy-mm-dd to apply to a directory, use is
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set today=%%c-%%a-%%b)
set homedir=E:\backups
set backuplog=E:\backups\LOGS\wk1-errors.log
set WK1List1=E:\backups\Lists\Week1_VMList_1.txt
SETLOCAL EnableDelayedExpansion
SET count=1
FOR /F "tokens=1 delims= usebackq" %%a IN ("%WK1List1%") DO (
SET var!count!=%%a
SET /a count=!count!+1
SET count=1
FOR /F "tokens=2 delims= usebackq" %%b IN ("%WK1List1%") DO (
SET var!count!=%%b
SET /a count=!count!+1
call :runbkup
)
:runbkup
echo "%%a backup started on %DATE% at %TIME%" >%backuplog% 2<&1
if exist %homedir%\%%a Rename %homedir%\%%a%_temp
start "%%a" cmd /c vcbmounter.exe -h vc2.domain.local -u domain\uid -p pwd -m `nbd -a ipaddr:%%b -r %homedir%\%%a -t fullvm -M 1
if exist "%homedir%\%%a" RD "%homedir%\%%a%_temp" /Q /S
echo "%%a backup completed on %DATE% at %TIME%" >>%backuplog% 2<&1
if exist "%homedir%\%%a_temp" echo "%%a was not successful on %DATE%-pls investigate" >>%backuplog% 2<&1
ENDLOCAL