proc main long lDate = 0 ;Hold long value representing date/time of file string sFname ;Contains full filespec of currently-latest file if findfirst "c:\windows\temp\test\*.*" "NRHSA" ;Search all files in specified directory sFname = $FILESPEC ;Set latest file to that of initial file lDate = $FLTIME ;Set time/date to that of initial file while findnext ;Continue searching hile more files remain if $FLTIME >= lDate ;If next file is newer than current latest file lDate = $FLTIME ;Set time/date to that of newly-found file delfile sFname ;Delete previously-latest file sFname = $FILESPEC ;Set latest file variable to the newly-found file else ;If file was not newer... delfile $FILESPEC ;Then delete newly-found file endif endwhile else ;No files found in specified directory usermsg "No files found!" endif endproc