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
Windows Server 2008

Avatar of undefined
Last Comment
Mahesh

8/22/2022 - Mon
Keelyn Henning

/e      Copies subdirectories. *Note that this option includes empty directories.*
SOLUTION
Keelyn Henning

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Keelyn Henning

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.
ASKER
jskfan

Can you paste the command using my paths and folders that I specified  as an example ?
Thank you
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Keelyn Henning

ROBOCOPY \\servernameA\sharenameA\folderA \\ServernameB\SharenameB\FolderB /MIR
Keelyn Henning

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
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
jskfan

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 .
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mahesh

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"
ASKER
jskfan

Sorry Mahesh,

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

Thank you
Your help has saved me hundreds of hours of internet surfing.
fblack61
Mahesh

NP Sir..

Thanks