: DELAGED Delete Files Older than Specified Age (Days) 10/04/1995-10/15/1999 : ---------------------------------------------------------------------------- : Copyright (C) 1995-1999 by Vladimir Veytsel www.davar.net : 1. Directory [and filespec] to be processed (Default: Entire current direct) : Symbol "#" should be used as a placeholder (stands for the entire curr dir) : when it is necessary to specify the following parameter[s] with 1-st defaulted : "?" - Display batch command text (Equivalent: "/") : Note: When only directory is specified (without filespec) : it should be closed by "\"; E.g.: A:\ or A:\BATCH\ : 2. Maximum file age (days) for a file to be kept (older files are deleted) : (Default: 30 days) ^^^^ : Symbol "#" should be used as a placeholder (stands for the age of 30 days) : when it is necessary to specify the 3-rd parameter with 2-nd being defaulted : 3. Non-empty value indicates that path part of the first parameter specifies : the directory to start deletion from and then proceed through all of its : subdirectories (Default: Delete aged files only within specified direct) : E.g.: DELAGED - Delete all files in current directory : that are older than 30 days : DELAGED #,7 - Delete all files in current directory : that are older than 7 days : DELAGED A:\BATCH\ - Delete all files in A:\BATCH direct : that are older than 30 days : DELAGED A:\CLIENT\MISCL\,10 - Del all files in A:\CLIENT\MISCL\ dir : that are older than 10 days : DELAGED A:\REFER\*.BKM,#,S - Del *.BKM files in A:\REFER directory : (and in all of its subdirectories) : that are older than 30 days @ECHO %TR% IF %1.==/. .OR. %1.==?. (LIST %_BATCHNAME ^ QUIT) SET DA2=%1 ^ IF %DA2%.==#. .OR. %DA2%.==. SET DA2=%_CWD\*.* SET DA1=%@PATH[%DA2%] ^ IF %DA1%.==. SET DA1=%_CWD\ SET DA2=%@FILENAME[%DA2%] ^ IF %DA2%.==. SET DA2=*.* SET DA3=%@DATE[] SET DA4=%2 ^ IF %DA4%.==#. .OR. %DA4%.==. SET DA4=30 IF NOT %3.==. SET DA5= (including %Y%subdirs%W%) @ECHO %W%Deleting %G%%@UPPER[%DA1%%DA2%] %W%files%DA5% that are older than %C%%DA4%%W% days%D% IFF %3.==. THEN FOR %F IN (%DA1%%DA2%) (IF %@EVAL[%DA3% - %@DATE[%@FILEDATE[%F]]] GT %DA4% DEL %F) : FOR %F IN (%DA1%%DA2%) (@ECHO IF %DA3% - %@DATE[%@FILEDATE[%F]] GT %DA4% DEL %F) ELSE IF %@UPPER[%3]==Y SET DA6=/Y FOR /R %DA1% %F IN (%DA2%) (IF %@EVAL[%DA3% - %@DATE[%@FILEDATE[%F]]] GT %DA4% DEL %F %DA6%) : FOR /R %DA1% %F IN (%DA2%) (@ECHO IF %DA3% - %@DATE[%@FILEDATE[%F]] GT %DA4% DEL %F %DA6%) ENDIFF UNSET DA1 DA2 DA3 DA4 SET DA5= SET DA6=