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

In Linux I know this command to find and list the latest modified files in a directory with all its subdirectories.

find /var/www/ -type f -exec stat --format '%Y :%y %n' {} \; | sort -nr | cut -d: -f2- | head

Is there a Windows CLI equivalent?

share|improve this question
are you looking for only modified files? Or are you looking at all files? – Keltari Feb 2 '13 at 17:25
I'm sure PowerShell can do this far more easily than batch, but if you absolutely must use the latter... Try dir /a-d /o-d /tw /s (show files only, order by date descending, use last write time for sorting, recurse into subdirs). However this will list all files. To limit the list to n latest modified files only, use dbenham's brilliant solution here. – Karan Feb 2 '13 at 17:43
A couple of comments on the Linux command: (1) Instead of -exec, you might want to consider xargs. (2) If you, as you say, want to sort an entire directory (sub)tree by modification date (and then look at the newest N), then what you have is reasonable. But if you can get the information you need by finding all files modified in the last N days, look at find … -mtime …. – Scott Feb 2 '13 at 20:41
To add to my previous comment, you can also look into forfiles /s /d +<date>. – Karan Feb 2 '13 at 23:22
up vote 5 down vote accepted

PowerShell 2.0

Latest 10 changed files

Dir C:\folder -r | ? {! $_.PSIsContainer} | sort LastWriteTime | select -last 10

Changed files since given date

Dir C:\folder -r | ? {! $_.PSIsContainer -AND $_.lastwritetime -ge '04/18/14'} 


share|improve this answer
dir c:\windows\ /aa /s /O-D

Lists all the files with the archive attribute set (modified) in the c:\windows folder and all its subfolders by date (newest first)

Edit: This method will only work if you clear the archive bits at some point or the list will just grow and grow.

share|improve this answer
What does the Archive attribute have to do with recently changed files? – Karan Feb 2 '13 at 17:10
Everything. Any file that gets changed gets the archive attribute set by the OS. Thats how backup programs know that a file has changed and needs to be backed up. – Keltari Feb 2 '13 at 17:15
Your edit is extremely important. Files with +A already will see no change. Why not find some way to do this based on Date Modified? – Karan Feb 2 '13 at 17:24

Take a look at MT Directory Changes Watcher. May be it is right for your needs.

Program watches for file changes in particular directory (Watch directory) and then copies changed files to another folder (Mirror directory) saving directory structure. This can be very useful when you have local copy of remote site and want to upload only files, changed locally after last upload.

share|improve this answer
Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill Jun 29 '15 at 10:05

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.