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.

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

2 Answers 2

up vote 3 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'} 

Read more on http://ss64.com/ps/

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

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.