Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch read variables from text, do robocopy
Name: khgust Date: June 5, 2009 at 05:21:02 Pacific OS: Windows XP and Server 2003 Subcategory: Batch
Comment:
I've been trying to create a batch file that reads a PC name and username from a text file and then executes a robocopy command. Once that command completes, it should go back to the text file and read the next set of data, etc. The text file is setup like: PC-1 JDoe PC-2 FGBar
Here is what I have, but I keep getting "The Syntaxt of the command is incorrect".
@ECHO OFF
setLocal EnableDelayedExpansion
for /f "tokens=1,2 delims= " %%a in ("PCs.txt") do (
SET PCTOBACKUP=%%a
SET BACKUPNAME=%%b
SET DESTDRIVE=\\MyServer
SET DESTFOLDER=%DESTDRIVE%\C-Drives$\%BACKUPNAME%_%PCTOBACKUP%
ECHO %PCTOBACKUP%
ECHO %BACKUPNAME%
ECHO %DESTFOLDER%
IF NOT EXIST %DESTFOLDER% MD %DESTFOLDER%
Robocopy \\%PCTOBACKUP%\c$ %DESTFOLDER% /MIR /R:0 /LOG:%DESTDRIVE%\C-Drives$\Running%BACKUPNAME%.LOG /TEE
copy %DESTDRIVE%\C-Drives$\Running%BACKUPNAME%.LOG %DESTDRIVE%\C-Drives$\Complete%BACKUPNAME%.LOG
del %DESTDRIVE%\C-Drives$\Running%BACKUPNAME%.LOG
)
I greatly appreciate any assistance. I had it working when just one line was in the text file, but I can't get it working again, and not really sure what went wrong. Thank you!
Summary: I have a text file with one line of text [may contain multiple words] that I need to 'read' back into my batch file as a variable. This variable is the directory where the user's IE Favorites will be ...
Summary: What would be the best way to read lines from a text file in java? The user gives me a text file which is already in a given format (i know how many lines the file has and which lines are Strings or i...
Summary: Hi, I would like to take in variable from a text file and execute them in the batch file till it is over Below is the batch file that I use: @echo OFF set /p requestid=Type requestid : set /p itemid=T...