Dear,

An example of the logfile output by running for the following
directories: c:\winnt\help + c:\windows\help
code:
2001/04/05 04:40:15 delete 'c:\winnt\help\31users.FTS' (2001/03/03 05:24:09 size=76800 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\31users.hlp' (1996/10/14 03:38:00 size=58591 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\access.FTS' (2001/03/03 05:24:08 size=94720 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\access.hlp' (1996/10/14 02:38:00 size=32359 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\accessib.chm' (2001/01/14 13:47:18 size=21705 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\accessib.cnt' (2001/01/14 14:35:02 size=121 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\accessib.hlp' (2001/01/14 14:35:02 size=16804 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\acc_dis.cnt' (1996/10/14 03:38:00 size=502 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\acc_dis.hlp' (1996/10/14 03:38:00 size=12643 older 3 days)
.....
2001/04/05 04:40:15 delete 'c:\winnt\help\wangshl.cnt' (1996/10/14 02:38:00 size=102 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wangshl.hlp' (1996/10/14 02:38:00 size=8509 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wordpad.cnt' (1996/10/14 02:38:00 size=1888 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wordpad.hlp' (1996/10/14 02:38:00 size=26793 older 3 days)

An example of the screen output:
code:
check directory 'c:\windows\help'
check directory 'c:\winnt\help'

Informative DELETION: process completed. 112 files deleted + 2 files skipped.

directories checked:
'c:\windows\help'
'c:\winnt\help'
debug output: 'c:\temp\deletion_debug.txt'

The debug output looks:
code:
days         3
current date 2001/04/05
compare date 2001/04/02

check directory 'c:\windows\help'
check directory 'c:\winnt\help'
2001/04/05 04:40:15 delete 'c:\winnt\help\31users.FTS' (2001/03/03 05:24:09 size=76800 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\31users.hlp' (1996/10/14 03:38:00 size=58591 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\access.FTS' (2001/03/03 05:24:08 size=94720 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\access.hlp' (1996/10/14 02:38:00 size=32359 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\accessib.chm' (2001/01/14 13:47:18 size=21705 older 3 days)
-skip- 'c:\winnt\help\accessib.cnt'
-skip- 'c:\winnt\help\accessib.hlp'
2001/04/05 04:40:15 delete 'c:\winnt\help\acc_dis.cnt' (1996/10/14 03:38:00 size=502 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\acc_dis.hlp' (1996/10/14 03:38:00 size=12643 older 3 days)
.....
2001/04/05 04:40:15 delete 'c:\winnt\help\wangocx.cnt' (1996/10/14 02:38:00 size=100 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\wangocx.hlp' (1996/10/14 02:38:00 size=19229 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\wangocxd.cnt' (1996/10/14 02:38:00 size=4415 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\wangocxd.hlp' (1996/10/14 02:38:00 size=291485 older 3 days)
2001/04/05 04:40:15 delete 'c:\winnt\help\wangshl.cnt' (1996/10/14 02:38:00 size=102 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wangshl.hlp' (1996/10/14 02:38:00 size=8509 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wordpad.cnt' (1996/10/14 02:38:00 size=1888 older 3 days)
2001/04/05 04:40:16 delete 'c:\winnt\help\wordpad.hlp' (1996/10/14 02:38:00 size=26793 older 3 days)

Our code is:
code:
;
; NT/95 delete files older then specified number of days - Kixtart 3.62, 3.63, 4.00
;
; (c) drillsergeant, mca - 2001
;
; vs 1.01 - program
;
; 1.00 (20010115) original version
; 1.01 (20010401)
;
CLS
BREAK on
FLUSHKB
MD "c:\temp"

IF (Len(@wksta) <> 0)
$wksta=@wksta
ELSE
$wksta="unknown"
ENDIF

; ---------------------------------------------------------------------------
; - site defined settings -
; ---------------------------------------------------------------------------

$debug_mode="yes" ; - yes/no -
$debug_file="c:\temp\deletion_debug.txt" ; - c:\temp\deletion_debug.txt = file
; - CON = means output to user screen

$days = 7 ; - delete files older than specified number of days -
$log_file="c:\temp\deletion_"+$wksta+".log" ; - append to this file -

$max_directories=2
DIM $remove_dir[$max_directories+1]
$remove_dir[1] = "c:\test1"
$remove_dir[2] = "c:\test2"

; ---------------------------------------------------------------------------
; - main program by DrillSergeant / MCA -
; ---------------------------------------------------------------------------

$temp_file="c:\temp\deletion.tmp"
$log_file=LCASE($log_file)
;
IF ($debug_mode = "yes")
DEL $debug_file
IF ReDirectOutput($debug_file)
ENDIF
ENDIF

; ---------------------------------------------------------------------------
; - Here you control whether files in subdirectories should be
; - or excluded, with the switch "/s".
; - The "/b" switch stands for "base notation", (which excludes
; - everything but the filename), don't change this one!
; ---------------------------------------------------------------------------

GOSUB "calculate_date"
?
IF Open(2,"$log_file",5)
ENDIF
;
$count_skipped=0
$count_delete=0
;
$i = 1
WHILE ($i <= $max_directories)
IF Close(1)
ENDIF
DEL $temp_file
? "check directory '"+$remove_dir[$i]+"'"
$command = '%comspec% /c dir "'+$remove_dir[$i]+'" /s /b >'+$temp_file
SHELL $command
IF (Open(1,$temp_file,2) = 0)
$line = ReadLine(1)
WHILE @error = 0
GOSUB "check_file"
$line = ReadLine(1)
LOOP
ENDIF
$i = $i + 1
LOOP
IF Close(1)
ENDIF
IF Close(2)
ENDIF
IF (Exist($temp_file) = 1)
DEL $temp_file
ENDIF
IF ReDirectOutput("CON")
ENDIF
? "Informative DELETION: process completed. "+
$count_delete+" files deleted + "+
$count_skipped+" files skipped."
?
? "directories checked: "
$i=1
WHILE ($i <= $max_directories)
? " '"+$remove_dir[$i]+"'"
$i=$i+1
LOOP
IF ($debug_mode = "yes")
? "debug output: '"+$debug_file+"'"
ENDIF
EXIT

; ------------------------------------------------------------------------
; - calculate the date (minus $days) by DrillSergeant - -
; ------------------------------------------------------------------------

:calculate_date
$cury = @year
$curm = @monthno
$curd = @mdayno
IF $curm < 3
$curm = $curm + 12
$cury = $cury - 1
ENDIF
$curint = $curd + ( 153 * $curm - 457 ) / 5 + 365 * $cury + $cury / 4 - $cury / 100 + $cury / 400 - 306
$myz = $curint - $days + 306
$myh = 100 * $myz - 25
$mya = $myh / 3652425
$myb = $mya - $mya / 4
$rd_year = (100 * $myb + $myh) / 36525
$myc = $myb + $myz - 365 * $rd_year - $rd_year / 4
$rd_month = (5 * $myc + 456) / 153
$rd_day = $myc - (153 * $rd_month - 457) / 5
IF $rd_month > 12
$rd_year = $rd_year + 1
$rd_month = $rd_month - 12
ENDIF
IF Len("$Rd_Month") = 1
$rd_month = "0" + "$Rd_Month"
ENDIF
IF Len("$Rd_Day") = 1
$rd_day = "0" + "$Rd_Day"
ENDIF
$compare_date = "$Rd_Year/$Rd_Month/$Rd_Day"
;
IF ($debug_mode = "yes")
? "days "+$days
? "current date "+@date
? "compare date "+$compare_date
ENDIF
RETURN

; ------------------------------------------------------------------------
; - check file for yes/no for deletion by DrillSergeant / MCA -
; ------------------------------------------------------------------------

:check_file
$time = GetFileTime($line)
IF ($time > "")
IF (Substr($time,1,10) < $compare_date)
$log_info=@date+" "+@time+" delete '"+$line+"'"+
" ("+GetFileTime($line)+
" size="+GetFileSize($line)+
" older "+$days+" days)"
IF WriteLine(2,$log_info+Chr(13)+Chr(10))
ENDIF
IF ($debug_mode = "yes")
? $log_info
ELSE
DEL $line ; <--------------------- delete files ------
ENDIF
$count_delete=$count_delete+1
ELSE
$log_info=" -skip- '"+$line+"'"
IF ($debug_mode = "yes")
? $log_info
ENDIF
$count_skipped=$count_skipped+1
ENDIF
ENDIF
RETURN

This please of code you can modify (site defined settings):
code:
 $debug_mode="yes"                        ; - yes/no -
$debug_file="c:\temp\deletion_debug.txt" ; - c:\temp\deletion_debug.txt = file
; - CON = means output to user screen

$days = 7 ; - delete files older than specified number of days -
$log_file="c:\temp\deletion_"+$wksta+".log" ; - append to this file -

$max_directories=2
DIM $remove_dir[$max_directories+1]
$remove_dir[1] = "c:\test1"
$remove_dir[2] = "c:\test2"

The script may give you an idea.
Greetings.

btw: change $debug_mode="yes" to "no" for really file
deletion.

btw: on the UDF forum all kind of UDFs are available to reduce some of above code.
Above code works for kixtart 3.6x and 4.x releases.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA