You can use the following syntax in Command Prompt (CMD) to search for directories by date:
forfiles /P "directory_path" /S /D +date /C "cmd /c if @isdir==TRUE echo @path"
In this example, the command will search for directories that were modified on or after the specified date within the given path and its subdirectories.
Note: The /P
flag specifies the path, the /S
flag specifies to search all subdirectories, and the /D
flag specifies the date. The +date
format means on or after the specified date.
The following example shows how to use this syntax in practice.
Example: How to Find Directory by Date in CMD
Suppose that we want to search for directories that were modified on or after January 1, 2023, within the following path:
C:\Users\admin\Documents\cmd_script
We can type the following command to search for the directories:
forfiles /P "C:\Users\admin\Documents\cmd_script" /S /D +01/01/2023 /C "cmd /c if @isdir==TRUE echo @path"
Output: 👇️
We can see that the command searches for directories modified on or after January 1, 2023, within C:\Users\admin\Documents\cmd_script and its subdirectories, displaying the full path of any matching directories.
Note: You can use the forfiles command followed by the path and the date to search for directories by date on your system.
Conclusion
I hope the above article on finding directories by date in CMD is helpful to you.
You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.