We help IT Professionals succeed at work.

Copying a folder with its subfolder using Robocopy

jskfan
jskfan asked
on
95 Views
Last Modified: 2018-03-27
Copying a folder with its subfolder using Robocopy

I have folderA in this path: \\servernameA\sharenameA\folderA
I need to copy it under path \\ServernameB\SharenameB\FolderB

So that when I go inside \\ServernameB\SharenameB\FolderB . I shoudl see folderA with all its subfolders and files. in other words the size of folderA in the source should be the same size as in the destination.

Copy /Past did not get the same size.
I would like to use Robocopy. So what are the right switches of Robocopy that can accomplish that ?

Thank you
Comment
Watch Question

Keelyn HenningIT System Administrator
CERTIFIED EXPERT

Commented:
/e      Copies subdirectories. *Note that this option includes empty directories.*
Keelyn HenningIT System Administrator
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Keelyn HenningIT System Administrator
CERTIFIED EXPERT

Commented:
I know this is a lot of information but here are all the options you have with Robocopy:

Option      Description
/s      Copies subdirectories. Note that this option excludes empty directories.
/e      Copies subdirectories. Note that this option includes empty directories. For additional information, see Remarks.
/lev:<N>      Copies only the top N levels of the source directory tree.
/z      Copies files in Restart mode.
/b      Copies files in Backup mode.
/zb      Uses Restart mode. If access is denied, this option uses Backup mode.
/efsraw      Copies all encrypted files in EFS RAW mode.
/copy:<CopyFlags>      Specifies the file properties to be copied. The following are the valid values for this option:
D Data
A Attributes
T Time stamps
S NTFS access control list (ACL)
O Owner information
U Auditing information
The default value for CopyFlags is DAT (data, attributes, and time stamps).
/dcopy:T      Copies directory time stamps.
/sec      Copies files with security (equivalent to /copy:DAT).
/copyall      Copies all file information (equivalent to /copy:DATSOU).
/nocopy      Copies no file information (useful with /purge).
/secfix      Fixes file security on all files, even skipped ones.
/timfix      Fixes file times on all files, even skipped ones.
/purge      Deletes destination files and directories that no longer exist in the source. For additional information, see Remarks.
/mir      Mirrors a directory tree (equivalent to /e plus /purge). For additional information, see Remarks.
/mov      Moves files, and deletes them from the source after they are copied.
/move      Moves files and directories, and deletes them from the source after they are copied.
/a+:[RASHCNET]      Adds the specified attributes to copied files.
/a-:[RASHCNET]      Removes the specified attributes from copied files.
/create      Creates a directory tree and zero-length files only.
/fat      Creates destination files by using 8.3 character-length FAT file names only.
/256      Turns off support for very long paths (longer than 256 characters).
/mon:<N>      Monitors the source, and runs again when more than N changes are detected.
/mot:<M>      Monitors source, and runs again in M minutes if changes are detected.
/MT[:N]      Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.
The /MT parameter cannot be used with the /IPG and /EFSRAW parameters.
Redirect output using /LOG option for better performance.
Note: The /MT parameter applies to Windows Server 2008 R2 and Windows 7.
/rh:hhmm-hhmm      Specifies run times when new copies may be started.
/pf      Checks run times on a per-file (not per-pass) basis.
/ipg:n      Specifies the inter-packet gap to free bandwidth on slow lines.
/sl      Copies the symbolic link instead of the target.

Author

Commented:
Can you paste the command using my paths and folders that I specified  as an example ?
Thank you
Keelyn HenningIT System Administrator
CERTIFIED EXPERT

Commented:
ROBOCOPY \\servernameA\sharenameA\folderA \\ServernameB\SharenameB\FolderB /MIR
Keelyn HenningIT System Administrator
CERTIFIED EXPERT

Commented:
And just a side note, I really like FreeFileSync over Robocopy. My easy to configure and faster in the transfer. And the best part about it is it's free!
Architect
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Mahesh,
robocopy.exe "\\servernameA\sharenameA\folderA" "\\ServernameB\SharenameB\FolderB\FolderA" /e /copyall /zb


when I go to folderB, I see all contents of folderA inside folderB. what I asked for was when I go to folderB, I should find just folderA, then I can open folderA and find all the subfolder and files .
MaheshArchitect
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
so I have provided command what you have asked for:

I have tested and it working as expected

Ex:
\\robocopy \\srv1\share1\fd1 \\srv2\share2\fd2\fd1 /copyall /e /zb
The command should copy "fd1" under "fd2"

Author

Commented:
Sorry Mahesh,

I guess I typed:
robocopy.exe "\\servernameA\sharenameA\folderA" "\\ServernameB\SharenameB\FolderB\" /e /copyall /zb

Author

Commented:
Thank you
MaheshArchitect
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
NP Sir..

Thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.