The title of this question is slightly misleading. Based on the questioner's xcopy
example, I believe the questioner wants to know "How to copy all files created...", not how to get all files (which I equate with list).
The questioner also states "file extension is .cmd or .bat". This could mean that the questioner wants to copy only files with these extensions but I think it means the questioner would like a batch script solution.
To use the following solution, open a command prompt and chdir
to the folder where the files to be copied are located. Then enter the commands listed below, changing the SET
values as appropriate.
SET DESTINATION=C:\destination
SET DATE_FROM=01/01/2005
SET DATE_TO=01/01/2007
> nul forfiles /S /D +%DATE_FROM% /C "cmd /C if @isdir==FALSE 2> nul forfiles /M @file /D -%DATE_TO% && > con ( echo @path && copy /V @path %DESTINATION% )"
Note: this will copy files in subfolders as well as files in the top-level folder.
The SET
values could be hard-coded directly into the > nul forfiles...
line, meaning only one line is required, but for clarity I've used variable substitution.
A caveat is that it is based on date modified
(original question asked for date created
)
Credit to aschipfl (https://stackoverflow.com/a/36585535/1754517) for providing the inspiration for my answer.