Hi Mark,

We use xxcopy utility to do that. but here is the sample script to do
this.

http://www.ultratech-llc.com/KB/?File=DelOld.TXT

Delete Files Older Than XX Days
Last Modified: 15 Aug 2001
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*** PLEASE NOTE: Link(s), If Provided, May Be Wrapped ***


The following batch file will step through the specified
starting folder (%@FOLDER%) and its subfolders, and delete
all files older than %@AGE%.

It requires the use of Windows NT4 or higher, and several
utilities from the Resource Kit, such as FORFILES and
ROBOCOPY v1.95 or higher.

The folder must be the shortname if entered at the command
line. Longname folders should be entered directly into the
batch file.


The syntax is:

        DELETEOLD.BAT folder age

Example:

        DELETEOLD D:\LOGS 25


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NOTE: The version below ("C") will only work in Win2K.
      See version "D" for a version compatible with
      both NT4 and Win2K.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ECHO OFF
 rem ==============================================================
 rem === Initialize Environment Variables
 rem === Last Modified On 06 Jul 2000
 rem ==============================================================
:Variables
 SETLOCAL
 SET @FOLDER=%1& IF /I "%1"=="" SET @FOLDER=C:\TEMP
 SET @AGE=%2& IF /I "%2"=="" SET @AGE=30
 SET @LOGFILE="%@FOLDER%\DeleteOld.LOG"


 rem ==============================================================
 rem === Recurse Through Subfolders And Delete Old Files
 rem === Last Modified On 17 Oct 2000
 rem ==============================================================
:SetFolders
 NOW Hunting Through "%@FOLDER%" And Subfolders For Old Files...
>%@LOGFILE%
 ECHO.                                                         
>>%@LOGFILE%
 ECHO.
 ECHO Hunting Through "%@FOLDER%" And Subfolders For Old Files...
 ECHO.
 FOR /F "TOKENS=*" %%D IN ('FORFILES -p"%@FOLDER%" -d-%@AGE% -s -c"CMD
/C ECHO @PATH\@FILE"') DO CALL :RemoveFiles %%D


 rem ==============================================================
 rem === Reset Environment Variables and Exit Batch File
 rem === Last Modified On 27 Jun 2000
 rem ==============================================================
:ExitBatch
 ENDLOCAL
 GOTO :EOF


 rem ==============================================================
 rem === SUBROUTINE: Remove Files That Are Over XX Days Old
 rem === Last Modified On 17 Oct 2000
 rem ==============================================================
:RemoveFiles
 rem %* = Current Filename
 ECHO.                   >>%@LOGFILE%
 ECHO -- Purging "%*"...
 ECHO -- Purging "%*"... >>%@LOGFILE%
 ATTRIB -R -S -H "%*"
 DEL "%*"                >>%@LOGFILE%
 GOTO :EOF



JOan

Mark Leith wrote:
> 
> Hi All,
> 
> To save me re-inventing the wheel:
> 
> Does anybody have a batch script (that runs on NT) that deletes archive log
> files that are older than X days old? I've looked at the DEL command, but
> this doesn't have a date/time based attribute parameter..
> 
> Has anybody been through this already?
> 
> All help appreciated!
> 
> Mark
> 
> ===================================================
>  Mark Leith             | T: +44 (0)1905 330 281
>  Sales & Marketing      | F: +44 (0)870 127 5283
>  Cool Tools UK Ltd      | E: [EMAIL PROTECTED]
> ===================================================
>            http://www.cool-tools.co.uk
>        Maximising throughput & performance
> 
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Mark Leith
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Joan Hsieh
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to