Robocopy does not copy the root folder and its time stamp - it copies all subdirectories and files (when the appropriate options are set) and there seems to be no option/argument to tell Robocopy you want the root folder itself and its time stamp or attributes to be copied verbatim also.

So say I want I want to copy C:/Brushes

Robocopy will copy all its subdirectories and files into the destination, but not the Brushes folder itself, with all associated attributes and time stamp.

You understand what I am asking? This is pretty basic and Robocopy seems to lack a option for it. People have posed the question before in various forums but as far as I'm concerned, no one has answered the question.

enter image description here

link|improve this question

20% accept rate
1  
This is a flyer, based on my experience with rsync, but what if you don't have a trailing slash at the end of your target folder? How about trying to modify the script at command-line level instead of using the GUI? I know for a fact that the command-line tool will do what you need. – Randolph West Jan 18 at 5:07
@Randolph West: presently I don't have a trailing slash at the end of the target folder. I still can't make Robocopy include the source folder and its attributes, etc. in the actual copy job. Any ideas? – ptrcao Jan 28 at 17:19
If there is no solution for robocopy, you could have a look at xxcopy (there are freeware and commercial versions). – harrymc Jan 29 at 16:16
Yep, I understand completely and have added a working solution below. The real problem is that you have to specify all the files and folders in the root NOT to copy. – opsin Jan 31 at 0:09
feedback

8 Answers

I agree with the OP, not being able to copy the root folder is a big shortcoming of robocopy. How about cheating and moving the brushes folder into a temporary folder, performing the robocopy operation on the temporary folder, then moving it back?

Something like:

md "c:\verytemporary" && move "c:\brushes" "C:\verytemporary"||( echo Line 1 error occurred & goto :eof )
robocopy c:\verytemporary d:\ /MIR /DCOPY:T
move "c:\verytemporary\brushes" "c:\" && rd /q "c:\verytemporary"||echo Line 3 error occurred
link|improve this answer
feedback

Try md D:\Backup\Brushes && robocopy C:\brushes D:\Backup\Brushes from the command-line, substituting the correct paths.

link|improve this answer
Yeah, but you are creating a new folder which will not have the attributes of the original C:\brushes folder...? – ptrcao Jan 28 at 17:18
feedback

If you combine /IF :: Include the following Files. with /E :: copy subdirectories, including Empty ones. you get (close to) the desired effect:

C:\Temp\Robocopy Source Root>robocopy . "C:\Temp\Robocopy Destination" /E /IF "Brushes*"
link|improve this answer
1  
What do you mean "close to"? What is the limitation you are implying? – ptrcao Jan 31 at 0:14
feedback

I don't have Robocopy available on this system to test, but try via command line:

robocopy C:\Brushes C:\Brushes.NEW C:\Brushes /S /E

It says here that it will take more than two file arguments, the third, etc. being "files to copy." Maybe if the directory is explicitly stated it will include it. I have never tried it.

You may also try using a wildcard that matches only that file in the first argument. This will require caution:

robocopy C:\Brushe? C:\Brushes.NEW /S /E

Again, not sure if that would work.

link|improve this answer
feedback

Robocopy isn't really designed to do that easily. However, there is a way.

Root folder contains lets say 50 files and 40 folders. You only want folder X (but you also want it's time and date stamp).

ROBOCOPY c:\ d:\ /XF 50 root file names c:\boot.ini c:\bla.txt etc. /XD c:\windows c:\drivers c:\temp etc. /S /E /SEC /DCOPY:T

The /DCOPY:T tells it to keep the folder time stamps. The /XF specifies which files NOT to copy, /XD specifies which folders to NOT copy. Just don't specify folder c:\X.

The main drawback to this is researching all the folders and file names in the root and specifically calling them all here. If you are doing this a lot on different systems a script could be written.

Working Example

robocopy c:\testing c:\abc /XF c:\testing\Testing.txt /XD "C:\testing\New Folder (2)" "C:\testing\New Folder (3)" /S /E /SEC /DCOPY:T

Root Working Example

robocopy c:\ d:\ /XF c:\Testing.txt /XD "C:\New Folder (2)" "C:\New Folder (3)" /S /E /SEC /DCOPY:T

My test worked, I create a few folders and sub folders, c:\testing was root in this case, c:\abc was root of another drive (obviously they aren't really, but for this purpose it should make sense). The folder I wanted from the root was called "New Folder", as you can see I did not specify it in the /XD. Also, make sure you specify the c:\ or the names you use will be global. In other words if I didn't specify c:\testing in from of the Testing.txt file, it would omit it from ALL of the subfolders being copied. The /SEC will copy all the file security and time stamps.

link|improve this answer
Hmmm, I suppose you could use /XF c:*.* to exclude all the root files. I'll test that when I'm in front of a machine and not on a phone. – opsin Jan 29 at 7:28
Nope, c:*.* is invalid, you'll have to manually list all of the files. – opsin Jan 29 at 19:34
feedback

user105198's answer is the half way,

D:\Backup\Brushes && robocopy C:\brushes D:\Backup\Brushes will indeed just create a new folder. You will need to append /MIR and /DCOPY:T to it

With the /mir option, if the destination directory exists, the destination directory security settings are overwritten. Technet

/DCOPY:T :: COPY Directory Timestamps.

combined together, means : the source directory's attributes and timestamps will be mirrored to the created folder.

so:

D:\Backup\Brushes && robocopy C:\brushes D:\Backup\Brushes /MIR /DCOPY:T
link|improve this answer
feedback

As I can see no good and easy solution in any of the answers :

If there is no solution for robocopy, you could have a look at xxcopy (there are freeware and commercial versions).

There are of course many other alternatives to robocopy, some are listed here.
See also Best Free File Copy Utility.

link|improve this answer
feedback
robocopy %1 "C:\DestinationDirectory\%~n1" /E /V /DCOPY:T /LOG:"C:\DestinationDirectory\Copied.txt" /R:10 /W:30 

Drop a folder onto the bat or use in Send To. It will create folder with name & time stamp of source directory and copy all files.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.