Search  
Sunday, May 20, 2012 ..:: Forums ::.. Register  Login
 Links Minimize

      

 Usefull Information Minimize
Search Forum Home 
 
     
  DOS and Batch Files  Batch Files  Delete Files by Date 
 
 Delete Files by Date 
 
 
host
0 posts
Delete Files by Date
Posted: 08 Oct 05 11:48 AM (N/A)
  

@echo off
goto :NoteEnd

--------------------------------------------------------
DelOld.cmd
-----------
Created: 06/01/05 by SJW

Purpose:   To delete files older than a given date

Notes:     You must set the StartDate and EndDate environment variables. 

Example:

N:
echo \SQLBackups\VPM\CPASsql\MSSQL\Backup\FRZ1999SQL
CD \SQLBackups\VPM\CPASsql\MSSQL\Backup\FRZ1999SQL
CALL \SQLBackups\DelOld.cmd


Revisions:

:NoteEnd


REM ** Format cutoff dates using YYYY/MM/DD
set StartDate=2005/01/01
set EndDate=2005/06/01

for /f "delims=" %%a in ('dir /b 2^>NUL') do call :PROCESS "%%a" %%~ta

goto :EOF

:PROCESS

REM ** Assumes date format is MM/DD/YYYY
for /f "tokens=1-3 delims=/" %%a in ('echo %2') do set CompDate=%%c/%%a/%%b

if /i "%CompDate%" LSS "%StartDate%" goto :EOF
if /i "%CompDate%" GTR "%EndDate%" goto :EOF

echo Deleting %1
del %1

:EOF

 

 
   
    DOS and Batch Files  Batch Files  Delete Files by Date 
     
   

Search  Forum Home         

Copyright 1991-2006 TinPanAlley BBS   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2012 by Perpetual Motion Interactive Systems Inc.