You are not logged in.
Pages: 1
We are trying to create a ROBOCOPY command that will output a log file that ends up just showing the date, filesize in bytes, and part of the destination directory path.
Thus the log file should look something like this,
20080602 66778899 2548
20080602 2233908 2548
20080602 9862234 2548
Here is the command we currently have,
robocopy e:\docs\gamnet\autofeeds\2548\ \\144.155.41.23\e$\gamnet\files\2548\2\ /r:02 /e /np >> e:\docs\gamnet\AUTOFEEDS\logs\%logfilename%
I have been tasked with figuring out which switches to put into this command so that the above logfile output happens.
I am thinking maybe I need the following switches:
/NDL
/NP
/NJS
/NJH
/BYTES
I am wondering, does /L have an effect on anything other than the log file itself?
If one puts /L switch into the ROBOCOPY command, does that cancel out the copying of the files from the source to the destination per the above command?
What's the best way to format the ROBOCOPY command so that it produces the desired log file output?
thanks in advance -
Tina Rock
Offline
/L will cause robocopy to show you what it would have done with the other options you supplied, without actually doing it. So in a roundabout way, that's a "Yes" on that question.
As for your main question, it's not going to be possible to achieve your requirements with "robocopy" alone, I'm afraid it's just not that flexible.
You're going to have to throw on a few more switches (/BYTES /R:02 /E /NP /TS /NDL /NJS /NJH /NC should do it), then do some work with the log file to pull the size, date and path apart, such that it all displays as you require.
Suffice it to say, this won't be a one-liner! ![]()
Last edited by bluesxman (05 Jun 2008 18:02)
CMD | *sh | KiX | AutoIT3 | PowerShell
Offline
Hi Bluesman,
thanks for the suggestions.
We tried modifying the command so that it was:
robocopy e:\docs\gamnet\autofeeds\2548\ \\144.155.41.23\e$\gamnet\files\2548\2\ /r:02 /e /np /BYTES /NDL /NJS /NJH /NC >> e:\docs\gamnet\AUTOFEEDS\logs\%logfilename%
however, the logfile produced merely said
ERROR : Invalid Parameter #6 : "/BYTES"
which I thought was kind of weird, since /BYTES is a listed switch for Robocopy.
Does the order of the switches matter?
Also the log file output didn't show the things I need, such as the bytesize for each copied file.
Do you have any suggestions or ideas?
thanks,
Tina Rock
Offline
The order of the switches doesn't matter, except that they're best placed at the end of the command line, as you have already done. You probably have version XP010 of robocopy then; it's not noted in the article, but I believe the /BYTES switch only works with version XP026 and, presumably, version XP027.
I only know of one way to get XP026 ... you must install the Microsoft Robocopy GUI (which isn't anywhere near as exciting as it might sound, by the way.) This will drop a copy of XP026 in your %windir%\system32 directory, which you can then copy/move around as you wish.
I should point out that a major draw back with XP026 is that, despite its extra functionality, it has a bug whereby it never returns an errorlevel other than 0, so it's very hard to catch errors.
If that's not acceptable, and you wish to pursue options with XP010, you'd have to drop the "/BYTES" switch in favour of the "/NS" switch (yes, I really do mean you should suppress size reporting -- due to some idiosyncrasies with this it makes life easier if we drop it altogether). Then, when post-processing the log, we'd have to do some jiggery pokery to get the file size from the OS; since we're going to have to do some work with the log file anyway, this shouldn't be too onerous.
Actually, side thought, if the target location isn't going to be empty, we need to add the "/XX" switch, lest we get some files in the log that we didn't mean to.
Once you're happy that robocopy is producing the log properly, I'll help you address the hacking apart thereof.
Last edited by bluesxman (06 Jun 2008 12:13)
CMD | *sh | KiX | AutoIT3 | PowerShell
Offline
How about we all take a breather from our mundane jobs and check what's new ... [deleted]
_____________
Edit: How about you take a break from posting SEO links on the forum!
Last edited by Simon Sheppard (09 Aug 2010 17:54)
Offline
Ive got a question to do with logs and robocopy if i may
Im using this command to produce a log
robocopy "%source%." "%target%." %_back_music% /R:0 /W:0 /XJD /XJF /nfl /ndl /njh /s /tee /xx /nc /l /XF %_exc_music_files% /XD %_exc_music_folder% "%target%." /log:%target%\sources.txt
so i end up with this
Total Copied Skipped Mismatch FAILED Extras
Dirs : 807 803 4 0 0 8
Files : 19217 19217 0 0 0 0
Bytes : 89.937 g 89.937 g 0 0 0 0
Times : 0:00:01 0:00:00 0:00:00 0:00:01Ended : Fri Sep 17 07:13:27 2010
is it possible to add a series of these together to produce a final copied total?
OR to reduce it to just a line of the total copied bytes eg: Bytes : 89.937 g 89.937 g 0 0 0 0
with the next one underneath as i only care about the amount that exists to be backed up
and one extra question i just thought of , is it possible to report in the log what the expected time to do the actual copy part of the robocopy would take if i ran the real robocopy process with the same parameters?
Thanks for any help
Last edited by Chimaera (17 Sep 2010 07:24)
Offline
I've always used xcopy in the past, but recently decided I need to becomefamiliar with RoboCopy. I found a sample batch file to back up folder(s) toan external drive. Modified it a little. And it does just what I need. When run manually it creates a log file with this command:
SET log_fname=%prefix%%date:~-4,4%%date:~-10,2%%date:~-7,2%.log
But I'm running it from Task Scheduler. It ran fine last night, the first time it was run. Everything backed up. But, no log file was created. How could running it from the scheduler affect that?
Offline
It shouldn't make a difference.
However...
Does "%prefix%" include a full path to the log file?
Have you specified the "Start in" location in the task? (WinXP here, maybe named differently in later versions)
I'm going to take an educated guess that the log file has ended up in "C:\WINDOWS\system32" or in the "Start in" location you may have specified.
If you haven't fully pathed the logfile location I suggest you do so.
If you have fully pathed it and it's still not there ... what user are you running it under? Maybe it doesn't have permission to write to the logfile location.
Last edited by bluesxman (09 Sep 2011 17:06)
CMD | *sh | KiX | AutoIT3 | PowerShell
Offline
Hi,
I'm trying to use robocopy on a Windows 2007 server to copy the last 2 weeks worth of most recent files in a folder called c:\temp to another server. is this possible with robocopy? The C:\temp folder has new files added every night and I need to copy these somewhere else but also keep them in the C:\temp folder.
If you have an example it will be very appreciated
Offline
Sounds pretty straightforward.
robocopy "c:\temp" "\\remoteserver\share" /maxage:14If you need to copy files in subdirectories, append "/s"
Last edited by bluesxman (19 Oct 2011 13:38)
CMD | *sh | KiX | AutoIT3 | PowerShell
Offline
Thanks! I was having this issue, your solution worked for me!
Offline
Pages: 1