Discussion:
Robocopy - not providing destination in log output
(too old to reply)
JMic
2009-06-18 20:41:01 UTC
Permalink
I am working with Robocopy to copy and move multiple files to multiple
directories. All is working well except for the logging. I am able to get the
log to output the source info but cannot get it to output the destination
directory without adding the job summary. I do not want to include the job
summary as this provides to much information for my logging requirements. I
don't want to move away from Robocopy just because of this one missing piece
but simpler apps like XCopy have this ability. I have tried the /fp switch
but this still does not list the destination directory.
Pegasus [MVP]
2009-06-18 21:41:39 UTC
Permalink
Post by JMic
I am working with Robocopy to copy and move multiple files to multiple
directories. All is working well except for the logging. I am able to get the
log to output the source info but cannot get it to output the destination
directory without adding the job summary. I do not want to include the job
summary as this provides to much information for my logging requirements. I
don't want to move away from Robocopy just because of this one missing piece
but simpler apps like XCopy have this ability. I have tried the /fp switch
but this still does not list the destination directory.
The destination directory is shown right up the top. It is the same for each
and every file:
Source : h:\
Dest : d:\HulDisk\

If you want to show it for every copied file then you could write a simple
little script that changes this log file line:
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
into this one:
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
d:\HulDisk\WINDOWS\system32\oobe\regerror\
JMic
2009-06-19 02:27:01 UTC
Permalink
I am sorry but I am not understanding what you are referring to when you say
"The destination directory is shown right up the top". Are you referring to
what is reported in the job summary or the job header? I have seen this in
the job summary but do not want all of the other information that comes with
adding this. Clearly the information is available through Robocopy but how do
I extract/parse this information into a simple log file? Here is a copy of
the syntax I am using currently:
echo %time%___%yr%_%mth%_%day% >>TodaysPages.log
C:\Utilities\robocopy C:\TEMP C:\TEMP\PrintSites na*.pdf /NP /R:3 /W:3 /IS
/IT /NP /NC /NS >>TodaysPages.log /NDL /NJH /NJS /R:3 /W:3

The log file results of this are:

16:12:59.39___2009_06_18

C:\TEMP\NATest1.pdf
C:\TEMP\NATest2.pdf
C:\TEMP\NATest3.pdf
Post by Pegasus [MVP]
Post by JMic
I am working with Robocopy to copy and move multiple files to multiple
directories. All is working well except for the logging. I am able to get the
log to output the source info but cannot get it to output the destination
directory without adding the job summary. I do not want to include the job
summary as this provides to much information for my logging requirements. I
don't want to move away from Robocopy just because of this one missing piece
but simpler apps like XCopy have this ability. I have tried the /fp switch
but this still does not list the destination directory.
The destination directory is shown right up the top. It is the same for each
Source : h:\
Dest : d:\HulDisk\
If you want to show it for every copied file then you could write a simple
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
d:\HulDisk\WINDOWS\system32\oobe\regerror\
Pegasus [MVP]
2009-06-19 11:06:18 UTC
Permalink
I recommend you modify your command by ommitting the following switches:
- The second /np (it's duplicated)
- The second /r:3 (it's duplicated)
- The second /w:3 (it's duplicated)
- /njh (so that you can see the header).
You will then see the following report:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
-------------------------------------------------------------------------------
Started : Fri Jun 19 13:00:37 2009
Source : C:\MYOB105\
Dest = d:\Fri\ *** This is the target folder ***
Files : *.exe
Options : /NS /NC /NDL /NJS /COPY:DAT /NP /IS /IT /R:3 /W:3
------------------------------------------------------------------------------
C:\MYOB105\drvwd32.exe
C:\MYOB105\drvxl32.exe
C:\MYOB105\DZPROG32.exe
C:\MYOB105\Myob.exe
C:\MYOB105\Myobopt.exe
C:\MYOB105\Myobupg.exe

If you don't want the header in your log file then you can write a simple
script that does the following:
- It reads the header
- It notes the target folder
- It writes the names of all copied files to a second log file, complete
with the target folder name on each line.
Post by JMic
I am sorry but I am not understanding what you are referring to when you say
"The destination directory is shown right up the top". Are you referring to
what is reported in the job summary or the job header? I have seen this in
the job summary but do not want all of the other information that comes with
adding this. Clearly the information is available through Robocopy but how do
I extract/parse this information into a simple log file? Here is a copy of
echo %time%___%yr%_%mth%_%day% >>TodaysPages.log
C:\Utilities\robocopy C:\TEMP C:\TEMP\PrintSites na*.pdf /NP /R:3 /W:3 /IS
/IT /NP /NC /NS >>TodaysPages.log /NDL /NJH /NJS /R:3 /W:3
16:12:59.39___2009_06_18
C:\TEMP\NATest1.pdf
C:\TEMP\NATest2.pdf
C:\TEMP\NATest3.pdf
Post by Pegasus [MVP]
Post by JMic
I am working with Robocopy to copy and move multiple files to multiple
directories. All is working well except for the logging. I am able to
get
the
log to output the source info but cannot get it to output the destination
directory without adding the job summary. I do not want to include the job
summary as this provides to much information for my logging
requirements.
I
don't want to move away from Robocopy just because of this one missing piece
but simpler apps like XCopy have this ability. I have tried the /fp switch
but this still does not list the destination directory.
The destination directory is shown right up the top. It is the same for each
Source : h:\
Dest : d:\HulDisk\
If you want to show it for every copied file then you could write a simple
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
d:\HulDisk\WINDOWS\system32\oobe\regerror\
JMic
2009-06-19 12:51:01 UTC
Permalink
I was affraid of this being the only option. Yes, what you suggest is
possible but only with additional coding and massaging of the original log
file output. I was hoping there would be something much simpler, like the
switch in XCopy that turns on the full file path showing both source and
destination without any additional coding/data massaging.

Thanks for the cleanup tips. I will implement these immediatly. If you or
others have any other suggestions as to how to proceed - please no VBS or
Perl suggestions as I am not well versed in either to make the switch, I
would be gratefull.

Cheers
Jmic
Post by Pegasus [MVP]
- The second /np (it's duplicated)
- The second /r:3 (it's duplicated)
- The second /w:3 (it's duplicated)
- /njh (so that you can see the header).
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
-------------------------------------------------------------------------------
Started : Fri Jun 19 13:00:37 2009
Source : C:\MYOB105\
Dest = d:\Fri\ *** This is the target folder ***
Files : *.exe
Options : /NS /NC /NDL /NJS /COPY:DAT /NP /IS /IT /R:3 /W:3
------------------------------------------------------------------------------
C:\MYOB105\drvwd32.exe
C:\MYOB105\drvxl32.exe
C:\MYOB105\DZPROG32.exe
C:\MYOB105\Myob.exe
C:\MYOB105\Myobopt.exe
C:\MYOB105\Myobupg.exe
If you don't want the header in your log file then you can write a simple
- It reads the header
- It notes the target folder
- It writes the names of all copied files to a second log file, complete
with the target folder name on each line.
Post by JMic
I am sorry but I am not understanding what you are referring to when you say
"The destination directory is shown right up the top". Are you referring to
what is reported in the job summary or the job header? I have seen this in
the job summary but do not want all of the other information that comes with
adding this. Clearly the information is available through Robocopy but how do
I extract/parse this information into a simple log file? Here is a copy of
echo %time%___%yr%_%mth%_%day% >>TodaysPages.log
C:\Utilities\robocopy C:\TEMP C:\TEMP\PrintSites na*.pdf /NP /R:3 /W:3 /IS
/IT /NP /NC /NS >>TodaysPages.log /NDL /NJH /NJS /R:3 /W:3
16:12:59.39___2009_06_18
C:\TEMP\NATest1.pdf
C:\TEMP\NATest2.pdf
C:\TEMP\NATest3.pdf
Post by Pegasus [MVP]
Post by JMic
I am working with Robocopy to copy and move multiple files to multiple
directories. All is working well except for the logging. I am able to
get
the
log to output the source info but cannot get it to output the destination
directory without adding the job summary. I do not want to include the job
summary as this provides to much information for my logging
requirements.
I
don't want to move away from Robocopy just because of this one missing piece
but simpler apps like XCopy have this ability. I have tried the /fp switch
but this still does not list the destination directory.
The destination directory is shown right up the top. It is the same for each
Source : h:\
Dest : d:\HulDisk\
If you want to show it for every copied file then you could write a simple
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
New Dir 8 h:\WINDOWS\system32\oobe\regerror\
d:\HulDisk\WINDOWS\system32\oobe\regerror\
Pegasus [MVP]
2009-06-19 14:11:16 UTC
Permalink
Post by JMic
I was affraid of this being the only option. Yes, what you suggest is
possible but only with additional coding and massaging of the original log
file output. I was hoping there would be something much simpler, like the
switch in XCopy that turns on the full file path showing both source and
destination without any additional coding/data massaging.
Thanks for the cleanup tips. I will implement these immediatly. If you or
others have any other suggestions as to how to proceed - please no VBS or
Perl suggestions as I am not well versed in either to make the switch, I
would be gratefull.
Cheers
Jmic
I'm somewhat baffled. People who post questions in a *scripting* newsgroup
are usually after some scripting solution, yet you specifically do not want
such a solution. In this case it might be better for you to repost your
question in a general type newsgroup (e.g. windowsxp.general) because you're
after a command that will combine the robustness of robocopy with the output
format of xcopy. Perhaps xxcopy.exe?

Anyway, I recommend you have a closer look at VB Scripts. They are a very
powerful solution for a great many problems. In your case a handful of lines
would do pretty much what you need when invoked like this:
cscript //nologo c:\Jmic.vbs < c:\robocopy.log > c:\robocopy.txt

[01] Set oInput = WScript.StdIn
[02] sDest = ""
[03] While Not oInput.AtEndOfStream
[04] sLine = oInput.ReadLine
[05] If sDest = "" Then
[06] p = InStr(1, sLine, "Dest = ", 1)
[07] If p > 0 Then
[08] sSource = Mid(sPrev, InStr(sPrev, ":") + 2)
[09] sDest = Mid(sLine, InStr(sLine, "=") + 2)
[10] End If
[11] sPrev = sLine
[12] Else
[13] If InStr(sLine, "\") > 0 Then WScript.Echo pad(sLine, sSource,
sDest)
[14] End If
[15] Wend
[16] oInput.Close
[17]
[18] Function pad (sString, sFrom, sTo)
[19] sString = LTrim(Replace(sString, vbTab, ""))
[20] If Len(sString) < 38 _
[21] Then sSpacer = Space(38 - Len(sString)) Else sSpacer = " "
[22] pad = sString & sSpacer & sTo & Mid(sString, Len(sSource)+1)
[23] End Function
JMic
2009-06-19 14:31:11 UTC
Permalink
I must respectfully disagree with you on this last comment. I consider a
batch file to be a form of scripting and invoking a Microsoft supplied
command line tool to be a part of that. My main concern was having to either
move away from an existing, working script (Batch file) servicing a large
production need for only logging reasons or find that I have missed something
with the current script/command line tools. I am not sure if this would be
considered ignorance or bad etiquette on my part though. :)

I am working on but have not graduated to using VB Scripts. When I get to
the same comfort level as I am with batch files, I will no doubt be
converting many of my current batch files to VB.

Thanks for the sample script. I will take this into the migration from batch
files to VBS shortly.

Cheers
JMic
Post by Pegasus [MVP]
Post by JMic
I was affraid of this being the only option. Yes, what you suggest is
possible but only with additional coding and massaging of the original log
file output. I was hoping there would be something much simpler, like the
switch in XCopy that turns on the full file path showing both source and
destination without any additional coding/data massaging.
Thanks for the cleanup tips. I will implement these immediatly. If you or
others have any other suggestions as to how to proceed - please no VBS or
Perl suggestions as I am not well versed in either to make the switch, I
would be gratefull.
Cheers
Jmic
I'm somewhat baffled. People who post questions in a *scripting* newsgroup
are usually after some scripting solution, yet you specifically do not want
such a solution. In this case it might be better for you to repost your
question in a general type newsgroup (e.g. windowsxp.general) because you're
after a command that will combine the robustness of robocopy with the output
format of xcopy. Perhaps xxcopy.exe?
Anyway, I recommend you have a closer look at VB Scripts. They are a very
powerful solution for a great many problems. In your case a handful of lines
cscript //nologo c:\Jmic.vbs < c:\robocopy.log > c:\robocopy.txt
[01] Set oInput = WScript.StdIn
[02] sDest = ""
[03] While Not oInput.AtEndOfStream
[04] sLine = oInput.ReadLine
[05] If sDest = "" Then
[06] p = InStr(1, sLine, "Dest = ", 1)
[07] If p > 0 Then
[08] sSource = Mid(sPrev, InStr(sPrev, ":") + 2)
[09] sDest = Mid(sLine, InStr(sLine, "=") + 2)
[10] End If
[11] sPrev = sLine
[12] Else
[13] If InStr(sLine, "\") > 0 Then WScript.Echo pad(sLine, sSource,
sDest)
[14] End If
[15] Wend
[16] oInput.Close
[17]
[18] Function pad (sString, sFrom, sTo)
[19] sString = LTrim(Replace(sString, vbTab, ""))
[20] If Len(sString) < 38 _
[21] Then sSpacer = Space(38 - Len(sString)) Else sSpacer = " "
[22] pad = sString & sSpacer & sTo & Mid(sString, Len(sSource)+1)
[23] End Function
Pegasus [MVP]
2009-06-19 20:21:29 UTC
Permalink
Post by JMic
I must respectfully disagree with you on this last comment. I consider a
batch file to be a form of scripting and invoking a Microsoft supplied
command line tool to be a part of that. My main concern was having to either
move away from an existing, working script (Batch file) servicing a large
production need for only logging reasons or find that I have missed something
with the current script/command line tools. I am not sure if this would be
considered ignorance or bad etiquette on my part though. :)
I am working on but have not graduated to using VB Scripts. When I get to
the same comfort level as I am with batch files, I will no doubt be
converting many of my current batch files to VB.
Thanks for the sample script. I will take this into the migration from batch
files to VBS shortly.
Cheers
JMic
I don't believe in converting batch files to VB Script files. Batch files
tend to be good at some things and lousy at others, and vice versa. String
manipulation is far more powerful and robust in VB Scripts than in batch
files. Performing everyday admin tasks such as copying/backing up files
takes far less effort in batch files than in VB Script files.

You could massage your robocopy log file with a batch file but it would be
painful, fragile and probably quite slow. With VB Scripts its easy - just an
exercise in basic string manipulation.

Loading...