|I figure you've gotten an answer by now, but I was bored so...|
@echo off & setlocal enabledelayedexpansion
if defined x goto :first
if %z% equ %prev% goto :countsecs
set /a cc+=1
if %cc% lss %timer% goto :countsecs
:this does the deletion: any file without "A" archive-bit set is killed.
:alternative: dir /b*.* >\temp then use temp as a list of files to delete.
for /f "tokens=*" %%a in ('attrib *.* ^| sort') do (
if "!ff!" equ "A " (
echo A is set, file not qualified for delete:!xy!
) else (
:disabled this for testing.
echo this file to delete:!xy!]
:remove the Archive attribute from all existing files (0 to 300 seconds old)
:these will be deleted on the next 5-minute cycle
attrib -a *.*
:or: dir /b *.* >\temp
echo 300 second countdown starting at %time%
:special handling for the first cycle: don't delete, just mark existing files
:crude attempt to test time format. prone to failure in unconventional environments!
if %test% equ %test2% (
echo no centiseconds!
) else (
I attempted to avoid any time comparisons or time-math, but you still might have issues if your time format is "exotic" (ask M2go about this date/time stuff, Lol!)