any way to copy files older than 2 days

John JY 221 Reputation points
2023-06-08T16:04:52.4966667+00:00

Hi all,

I need to copy users' profiles to another location.

I used robocopy. robocopy \server1\userdata \server2\userdata /s /e /mt /zb /XO /r:1 /w:1 /copy:DATSO and checked logs and it still shows me all directories copied and not files copied. Guess that's supposed to be? any better way to copy only two days changes data?

Thank you!

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,506 Reputation points
    2023-06-09T12:30:49.9366667+00:00

    Start by running "robocopy /?" and review the help output.

    If you want to copy based on file age, you have to tell robocopy how long. I don't think that you will need the /XO switch.

    /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
    /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.	
    

    Use the /l switch to test robocopy. It will just list what it will do without actually copying any files.

    This command will copy files that have NOT changed in the past 2 days.

    robocopy c:\temp\foo1 c:\temp\foo2  /e /mt /zb /r:1 /w:1 /copy:DATSO /minage:2 /l 
    

    This command will only copy files that have been changed in the past 2 days.

    robocopy c:\temp\foo1 c:\temp\foo2  /e /mt /zb /r:1 /w:1 /copy:DATSO /maxage:2 /l
    

    Note that robocopy will not report on the file names if they already exist in the destination folder. You can add the /v switch to have it report on all files.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.