Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Mar 28 '13 at 0:22

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

1 Answer 1

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

 
discard

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