Solved

Robocopy - correct switches to use

Posted on 2009-06-30
9
675 Views
Last Modified: 2012-05-07
I have been trying out Robocopy to do some archiving work.
The version of Robocopy I am using is v5.1.1.1010 (don't know if there is a more up to date version)
I tried what I consider to be a basic command (in a batch file) as follows;

robocopy "N:\IT\Temp\Test" "R:" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30

Extract from the log file shows that 3 files were copied, but no directories.
See below
------------------------------------------------------------------------------
                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :         1         0         1         0         0         9
    Files :         3         3         0         0         0         6
    Bytes :    60.5 k    60.5 k         0         0         0   39.42 m
    Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   What has happened was that although the Source has the files 3 levels below the root (N:), the copied files were all stored in the root of the Destination (R:).
I had expected the sub-folders to be re-created on R: which did not happen.
I have since tried /S and /CREATE . Even /MIR although I have no wish for source files to be purged after the copy.

I would appreciate if some experts could point out the errors in the command.
Thanks
0
Comment
Question by:garychu
  • 6
  • 3
9 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24751669
this will give you everything. This is what I use, (Copy)

robocopy "C:\Documents and Settings\" "D:\Backup\Documents and Settings\" /S /V /TS /FP /LOG+:"Documents&Setting.txt" /Z /R:10 /W:30

And I am using the same version as you are as well.

Good Luck
Carrzkiss
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24751673
sorry. to many slashes


robocopy "C:\Documents and Settings" "D:\Backup\Documents and Settings" /S /V /TS /FP /LOG+:"Documents&Setting.txt" /Z /R:10 /W:30

Carrzkiss
0
 

Author Comment

by:garychu
ID: 24759998
Thanks, Carrzkiss.
Sorry if I did not explain the issue well enough.
robocopy "N:\IT\Temp\Test" "R:\IT\Temp\Test" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30
works perfectly just like you demonstrated in your example.
It is when the full path is not stated for both Source and Destination that I hit a problem.
It is not always convenient to have to pre create the destination directory structure in advance (using /CREATE I presume, without having tried it yet).
Thus I had used
robocopy "N:\IT\Temp\Test" "R:" /E /COPYALL /V /NP /LOG:"robo-test-copy-log.txt" /R:10 /W:30
instead, thinking that the /E switch will create the necessary folders. Introducing the /MOV switch also did not make a difference.
Robocopy is such a powerful tool. It can't be so dumb in this respect. So my guess is I have not used the correct switches (or event sequence of switches for all I know!)
Thanks again for your interest in this question.

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24760035
OK
Are you stating that you want the directory structure to be created into the new drive as such:

R:\IT\Temp\Test

Sorry, you will have to put in the pre-defined destination path.
Just like my example.

Sorry, but I do not think that it will do it without that information, But I could be wrong.
But I have been using RoboCopy for about 5 yrs now, and I have never seen anything as
To what you are wanting.

Good Luck
Carrzkiss

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:garychu
ID: 24768149
Thanks again, Carrzkiss.
Actually I do not think my requirement is all that unique and unusual.
Consider this scenario.
I have a folder on a file-server with a large number of sub-folders and files. Changes to directory structure, addition/deletion of sub-folders happen all the time.
I wish to use robocopy to move files of a given age to another disk volume prior to being archvied. But I need to have the original (source) directory structure preserved.
It would be quite impractical to have to manually create empty sub-folders each time in advance of the move.
I have tried the /CREATE switch - but it does not seem to work as I have expected it to.
Perhaps you can suggest a suitable command line making use of the /CREATE switch which should also help in my situation.
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
ID: 24769214
You do not create the "Empty Sub Folders"
Example
"N:\IT\Temp\Test"
The above is your structure of the folder directory correct? Right.
OK.
Now, you want to copy the files over to the archive drive like so
"R:\IT\Temp\Test"
No, you do not phisically have to create the folders.
The program does that for you.
YOU HAVE to write the directory structure out within the script.
If not, then lets say you do this.

"R:\Archive"
Now, you point it to that archive, and it is going to dump straight into there, and list all the folders that
Are in \Test
Now
You write it out as:   "R:\Archive\IT\Temp\Test"
Then it is going to drop all the contents into here.
And thus keeping your folder structure the same.

---------
Now.
Source
"N:\IT\Temp\Test"
Desitination
 "R:"
With some switches thrown, will still NOT create that Structure of:  R:\IT\Temp\Test
Not without having it written out within the script as I have done above.

Good Luck
Carrzkiss
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24769223
Did some reading on the /CREATE
And it suppose to ONLY create the Folder structure only.
But seems that it does not quite work as expected.

I will test it later on if I have the time.
Right now I am trying to get a web site finished and released.
As it seems that it is taking longer then expected.

Good Luck
Carrzkiss
0
 

Author Comment

by:garychu
ID: 24774982
Yes - I think I have got it.
Robocopy copies everything that is in a folder (if not excluded). In effect this means including sub-folders and files if the /S or /E switches are used.
Thus in my example, I should have used just N:\IT as source and R: as destination.
All items within N:\IT will be created, including empty sub-folders completely in R:

Thanks again for the patience and time taken to explain the issue.
Good luck on your website!
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 24775444
Not a problem
Hope it all works out for you.
(Why the B though?)

And thanks for the Luck
I am going to need it.
I am going to spend the entire weekend on it, and "Try" to take some time off tomorrow
To spend the 4th with my Son, and do something.
Then back at it again. I am hoping to approach the locl hospitals with the site on monday.
So. Got to make sure everything is working perfectly with it.

Enjoy.
Carrzkiss
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows XP image 11 109
Asus ks2003 driver XP 32 33 68
active directory 5 44
how to copy from computer to usb drive 7 64
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now