Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

Copying a folder with its subfolder using Robocopy

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
Avatar of Keelyn Henning
Keelyn Henning
Flag of United States of America image

/e      Copies subdirectories. *Note that this option includes empty directories.*
SOLUTION
Avatar of Keelyn Henning
Keelyn Henning
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of jskfan

ASKER

Can you paste the command using my paths and folders that I specified  as an example ?
Thank you
ROBOCOPY \\servernameA\sharenameA\folderA \\ServernameB\SharenameB\FolderB /MIR
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!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

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 .
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"
Avatar of jskfan

ASKER

Sorry Mahesh,

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

ASKER

Thank you
NP Sir..

Thanks