Recently discovered an awesome little batch command that’s apparently been around forever and I’ve never heard of it.

Have you ever wanted to search a directory from the command line for all files older than a year? Or wanted to search for all txt files newer than a certain date?

And wanted to do it all without writing a massive for loop or powershell command?

Use forfiles!

To list all of the files in the current directory that are at least one year old, type:

forfiles /s /m *.* /d -365 /c "cmd /c echo @file"

Check it out!