Is this possible with Robocopy
Is it possible with robocopy to move files from folder-B to folder-C if they also exist in folder-A? Can't change the contents of Folder-A. Folder-A - e:\restore_1 Folder-B - e:\restore_2 Folder-C - e:\duplicate_files
September 15th, 2012 12:51pm

Hi, As far as I know, we can specify many options in the Robocopy command line tool to achieve our target. Regarding your request, I suggest we could refer to the following article to see if there are some examples of the command could help us to achieve the target. Robocopy and a Few Examples http://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx For more detailed information about Robocopy, please refer to the following articles. Robocopy http://technet.microsoft.com/en-us/library/cc733145(v=ws.10).aspx Get to Know Robocopy for More Powerful File Management http://technet.microsoft.com/en-us/magazine/ee851678.aspx Here is the article about Robocopy GUI tool, its easy to create Robocopy command for us with this tool. Utility Spotlight http://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx Regards, Andy
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 5:37am

There are no options to robocopy that allow you to add a third location into the mix; comparisons are done between a source directory and a target directory. It IS possible to do something akin to what you ask using other tools; one straightforward way involves using PowerShell. What are your options other than Robocopy? Also, do you want to MOVE files B->C or did you mean COPY? If you CAN use PowerShell, for example, here's a quick example of how this would work when simply copying. $AFiles = Get-ChildItem -Recurse e:\restore_1 $BFiles = Get-ChildItem -Recurse e:\restore_2 Compare-Object $AFiles $BFiles | ?{$_.SideIndicator -eq "=>"} | %{Copy-Item $_.InputObject.FullName e:\duplicatefiles
September 17th, 2012 11:41am

Andy, I did check out robocopy and the links you referenced. Some real good info but no reference to using a 3rd folder for comparison. Alex - thanks. I will test. I have started looking at ps. What does SideIndicator do?
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 11:50am

Alex - I need to learn more here. kept trying to do this, first with a foreach statement. That worked but took a very long time. Then I pulled this off another thread. $folderA='y:\sourcefolder\' $folderB='x:\somefolder\*' dir $folderB | %{move "$folderA$($_.Name)" $folderC -force} Can you help me understand what your compare-object line does? And, which folder would this copy from? Thank you, this is good. :)
September 17th, 2012 2:08pm

When you run objects through Compare-Object, by default it returns objects which are unlike in the reference ($AFiles) and difference ($BFiles) sets. SideIndicator is an "arrow" pointing left ("<=") for items in the first or reference set only and right ("=>") in the second or difference set. By the way, my example will dump all the copied B-only files into e:\duplicatefiles directly, no subdirectories. If you need to maintain structure, there's another element to work on in the script.
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 2:14pm

Thanks Alex!
September 20th, 2012 8:56am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics