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?
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/
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.
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.
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.-exec
, you might want to considerxargs
. (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 atfind … -mtime …
.forfiles /s /d +<date>
.