Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to copy one file that is the newest in whole catalog. How to do it using robocopy? I know /xo and /xn options but it doesn't do what I need.

share|improve this question

migrated from Mar 28 '13 at 0:22

This question came from our site for professional and enthusiast programmers.

Interesting idea, does it have to be done with RoboCopy?

I would try something like this using PowerShell:

(Get-ChildItem -Path Path:\to\files\here -Recurse -File | Sort-Object -Descending LastWriteTime)[0] | Copy-Item -Destination Path:\to\destination\here -Force

So to do that in robocopy, you can just use the (Get-ChildItem -Path Path:\to\files\here -Recurse -File | Sort-Object -Descending LastWriteTime)[0] part and set it to a variable, and pass it in to a RoboCopy line.

Robocopy is good for mirroring and transferring lots of files/directories, but it doesn't do delta style copies so it might not be the best for this situation. I also took a guess you meant last file written to, you could use LastAccessTime if that fits better.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.