Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 4
    Excellent...I was searching for how to get the most recent file, and the code example you give is the exact reason I'm searching for this, restoring a sql server backup!
    – tbone
    Commented Aug 25, 2009 at 21:09
  • 1
    This was helpful. Just a note to say, if your files are inconveniently in subdirectories (like mine are), you can use the '/S' flag in DIR to check recursively. i.e. insert '/S' after DIR above and it should work.
    – user7094
    Commented Aug 1, 2011 at 9:13
  • @ObligatoryMoniker : What is %%I?
    – Ashwin
    Commented May 8, 2012 at 8:26
  • How do I filter by Date only and not Date and Time? /O:D Commented Feb 3, 2014 at 14:00
  • 1
    @Ashwin, %%I is the iterator in the FOR loop
    – CrazyTim
    Commented May 15, 2014 at 2:52