(view source code of listfilesbetween.bat as plain text)
:: Check Windows version
:: Exactly 3 mandatory command line arguments plus optional /S switch
:: Check if file or directory exists
:: Check if dates are valid for use with XCOPY's /D switch
:: Use a local environment
:: Check if file or folder
IF ERRORLEVEL 1 (
IF "%~nx3"=="" (
) ELSE (
IF "%Arg3:~-1,1%"=="\" (
:: List all files after and including TO date in a temporary file
XCOPY "%Arg3%" C:\*.* /D:%~2 %4 /H /Y /L | FINDSTR /R /B /V /C:"[1-9][0-9]* " > "%Temp%.\~%~n0.tmp"
:: Now list all files older than and including FROM date, and only
:: display its path if the file is NOT listed in the temporary file
:: Delete the temporary file
ECHO List matching files last modified between two dates
ECHO Usage: LISTFILESBETWEEN from_date to_date file_spec [ /S ]
ECHO Where: from_date is the earliest timestamp to be included
ECHO. to_date is the day after the last timestamp to be included
ECHO file_spec is the folder or file specification
ECHO /S includes subfolders
ECHO the order MM DD YYYY is fixed, the delimiter depends on the locale.
ECHO The file_spec must be a fully qualified path, i.e. drive:\path[\files]
ECHO or \\server\share\path[\files]; wildcards are allowed.
ECHO Files with timestamps equal to from_date are included, files with
ECHO timestamps equal to to_date are excluded; to include today's files
ECHO Matching hidden files are included.
ECHO Written by Rob van der Woude
:: Abort with errorlevel 1 without using EXIT
IF "%OS%"=="Windows_NT" COLOR 00
page last modified: 2023-03-10