Read TXT file Loop through till EOF
Posted on 2013-05-20
I'm still a novice at writing batch scripts. I need to create a script to do backups of user profiles. I have a TXT file that has a list of all computer IP's and OS version. In this format:
"WINXP - 10.10.10.1". I am using Robocopy to copy the files. So far I am able to set variables for OS and IP and use them. The problem I'm having is reading through the TXT file to the EOF. What's happening is the program is not reading pass the first record. It keeps looping the first record. I need it to advance to the next line after it processes the previous record. Here is the code I have so far, remember I'm new at this so please keep it simple.:
for /F "tokens=3*" %%A in (AllIPList.txt) do (
for /F "tokens=1" %%B in (AllIPList.txt) do (
ECHO My Address is %%B
ECHO My IP is %%A
if %%B==WIN_7 (
) else if %%B==WINXP (
) else if %%B=="" (
ECHO Its Windows 7
Robocopy.exe \\%ipvar%\C$\Users G:\\Profiles\%ipvar%\ /MIR /W:0 /R:0 /NP /XF *.tmp *.log /XD LocalService NetworkService temp "temporary internet files" cache Administrator "John Doe" Default Public /LOG:"C:\Users\MyDirectory\Documents
ECHO Its Windows XP
Robocopy.exe "\\%ipvar%\C$\Documents and Settings" G:\\Profiles\%ipvar%\ /MIR /W:0 /R:0 /NP /XF *.tmp *.log /XD LocalService NetworkService temp "temporary internet files" cache Administrator "John Doe" "Administrator.*" "All Users"
"Default User" /LOG:"C:\Users\MyDirectory\Documents\Backup Project\%ipvar%.txt"
ECHO End of file reached Exiting program!!!