Have a need to find files in a folder that are older than X hours. Have to do this in batch because this is an older server that we don't want to load anything else on. This is based on Find out if file is older than 4 hours in Batch file, but that solution was written for only for one static filename. I have adjusted it for multiple files, and US date format, but the problem I am having in the file minutes it is picking up the 'a' or 'p' for am or pm. I have posted my partial solution below (does not perform date math and echos to screen filename and date/time values). Any ideas on how to get rid of a or p?
rem extract current date
for /f "tokens=1-5 delims=.,/ " %%a in ("%date%") do (
set day=%%c&set mon=%%b&set yr=%%d
)
REM Extract Current Time
for /f "tokens=1-5 delims=.:, " %%a in ("%time%") do (
set hr=%%a&set min=%%b
)
REM BUILD LIST OF FILES IN DIRECTORY
dir /B /O:N c:\mydir\*myfilestub*.* >list.txt
Rem LOOP THROUGH LIST OF FILES and CALL SUBROUTINE TO CHECK FILE DATE
For /F %%A in (list.txt) DO (CALL :CHECKFILE %%A)
GOTO :EOF
:CHECKFILE
REM CHECKING FILE %*
set filename=%*
rem extract file date and time
for /f "tokens=1-5 delims=.:,/ " %%a in ('"dir c:\mydir\%filename%|find "%filename%""') do (
set fday=%%a&set fmon=%%b&set fyr=%%c&set fhr=%%d&set fmin=%%e
)
ECHO %FILENAME% %fday% %fmon% %fyr% %fhr% %fmin%
GOTO :EOF