Error with robocopy in batch file

404 Views Asked by At

I have this batch file to copy all file from one directory to another directory. The source and destination directory are write in a text file. So I have this:

BATCH FILE

for /f "delims=: tokens=2,3" %%j in (C:\temp\copy_list_test.txt) do ROBOCOPY.EXE %%j %%j\..\BACKUP *.* /R:2 /W:5 /log+:%%j\..\LOGS\GOLD2MES.log & ROBOCOPY.EXE %%j %%k *.* /R:2 /W:5 /MOV /log+:%%j\..\LOGS\GOLD2MES.log

and this is a copy_list_test.txt file

TC C2 #001 from instrument to C:\temp\GOLDS\IMPORT:C:\temp\MESSE\IMPORT

So when I try to run the script he create a new folder on "C:\Users\mcastrio\Desktop\C\" and not put file in C:\temp\MESSERVER

Where is my error?

Can we help me? Best reguards

1

There are 1 best solutions below

0
On BEST ANSWER

As you are using colons as delimiters in the input file, the tokenizer sees

TC C2 #001 from instrument to C:\temp\GOLDS\IMPORT:C:\temp\MESSE\IMPORT
^.............................. ^................. ^ ^.................
1                               2                  3 4

That is,

%%j = \temp\GOLDS\IMPORT
%%k = C

You can change your tokens clause to tokens=2,* to obtain

TC C2 #001 from instrument to C:\temp\GOLDS\IMPORT:C:\temp\MESSE\IMPORT
^.............................. ^................. ^.................. 
1                               2                  3 

But remember the drive reference in %%j has been lost.