Robocopy - Timestamps for Folders (moving files and folders to a new PC)

David C 21 Reputation points
2021-12-14T19:54:04.39+00:00

Greetings,

I did some searching about how to use Robocopy. I'm trying to copy files from my old PC (Win 7) to my new PC (Win 10 Pro), but I want to retain the timestamps for files AND folders.

From the command prompt on my old PC, I've tried putting the files on a USB with:
Robocopy [source] [destination] /s /copy:DAT /dcopy:DAT
[source} = "C:\Users\DWC\My Documents\Animals" (Animals has several sub-folders with files)
[destination] = "F:"

On my NEW PC I used Robocopy to copy from the USB:
Robocopy [source] [destination] /s /copy:DAT /dcopy:DAT
[source] = "F:"
[destination] = "D:\DWC\My Documents"

On the new PC, all the Timestamps for the folders within "Animals" are correct, but the Create timestamp for the "Animals" folder is the system date and time.

I then thought maybe Robocopy was not keeping the Timestamps of the "Animals" folder so I tried various other methods like using Robocopy to put the "Animal" folder (with sub-folders and the files) into a new subfolder on the USB, then using Robocopy to copy that new sub-folder to the new PC. Still no luck.

What am I doing wrong?

Eventually, I'll need to move 527GB of folders and files from my old PC (C:\Users\DWC\My Documents) to my new PC (D:\DWC\My Documents). I thought I'd try moving one folder to see how Robocopy works before attempting to move more data by using my external hard drive.

PS - I hope I've posted with the correct tag. I've noticed several questions about Robocopy appear with several different tags.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,727 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 34,431 Reputation points
    2021-12-14T23:05:57.437+00:00

    I included the folder name on both source and destination, and it copied the timestamp.

    robocopy c:\temp\foo1  c:\test\foo1 /s /copy:DAT /dcopy:DAT
    

    You could also use Powershell to copy the timestamp from another folder. (Or use get-date and construct whatever timestamp you want.)

     (get-item -Path "C:\temp\foo1").LastWriteTime =  (get-item -Path "C:\temp\foo2").LastWriteTime 
    
    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. David C 21 Reputation points
    2021-12-15T00:25:51.993+00:00

    Thanks MotoX80.

    When I first tried it, I omitted the folder ("Animals") on the destination. I figured Robocopy would complain if the folder was not present in the destination.

    I also noticed you used "/dcopy:T", where I had used "/dcopy:DAT". I'll try Robocopy again on another folder using "/dcopy:DAT", but I'll include the folder name on the destination. I don't really know if I need to copy the Data and the Attributes for the folder or not, but I do need the Timestamp.

    David


  2. David C 21 Reputation points
    2021-12-15T01:38:32.37+00:00

    I see that now. Glad I'm going for new eyeglasses tomorrow :)

    0 comments No comments

  3. JohnyBenz 321 Reputation points
    2022-11-05T08:37:33.707+00:00

    it's possible to preserve all timestamps in the copied output, including those of directories and their attributes.

    Eg:

    Code:

    robocopy.exe "<source>" "<destination>" *.* /E /V /R:1 /W:5 /COPY:DATS /DCOPY:DAT  
    

    Replace <source> and <destination> with the appropriate directory paths, obviously.

    . = match all files
    /E = Copy sub-directories, including empty ones
    /V = Verbose output, showing any skipped files
    /R:1 = Number of retries on failed copies (in millions)
    /W:5 = Wait time between retries (in seconds)
    /COPY:DATS = Copy files' original Data (D), Attributes (A), Timestamps (T), NTFS ACL (S). (Personally I don't normally copy ACL info.)
    /DCOPY:DAT = The above but for directories.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.