If you want to sort files by last modified date in a folder, I would suggest you use PowerShell for this task. PowerShell makes it extremely easy to create a list of files by modified date. Here is a snippet you can use to create a files.dat including files list sorted by date:

gci -rec -file | sort LastWriteTime -Descending | select-object fullname,lastwritetime | out-file "files.dat" -width 4096


You can use copy and paste this line to a PowerShell terminal, or you can save it in a text formatted file with ps1 extension. When you right click and select Run With PowerShell option on that file, it will create files.dat with your files list.


gci -rec -file | sort LastWriteTime -Descending | select-object fullname,lastwritetime | out-file "files.dat" -width 4096

If you want to learn or extend this snippet, let me explain each step for you.

  • gci -rec -file
    This line is an alias for Get-ChildItem -Recurse -File. As you can understand it gets a list of files including subfolders using recursive search.
  • sort LastWriteTime -Descending
    This part sorts all files using LastWriteTime column/property in Descending order, that is last modified file will be on top.
  • select-object fullname,lastwritetime
    We select only full path and lastwritetime, so other extra information is not needed
  • out-file "files.dat" -width 4096
    This section redirects all text output to "files.dat"

I hope you find this snippet useful somewhere, Enjoy!

Join The Discussion