Ok, so here's another "if file is older than... delete". But anyway... I was looking for an easy way to do this on, which wasn't XXXkb of scriptcode, and since I couldn't understand a
of the advanced one described here, I tried to do my own 
So I worked some more on cj's script , which I didn't get to work with the dates comparison... 
I ended up with the script below, in which I cannot seem to get the "GetFileTime()" function to work. Although this script will not generate exact dates, but it will do for me 
Another thing that would be great is to be able to have multiple directories, I believe this may be possible with some sort of Array? I don't know how to do this..., any1? The faulty results are described below...
code:
; ===================================================================
; === Script to delete files older than $DelDayCount number of days
; === in a directory.
; ===================================================================
BREAK ON
CLS;=== Set your number of days for "files older than" to be deleted,
;=== and the directory to look in (ex: ...=dir("C:\deltest\*.txt).
$DelDayCount = "90"
$FileName = Dir("C:\datetest\*.*")
While $FileName <> "" AND @ERROR = 0
IF $FileName = "."
$FileName = Dir()
ENDIF
IF $FileName = ".."
$FileName = Dir()
ENDIF
;=== Get the file date (comes in YYYY/MM/DD).
$FileDate = GetFileTime("$FileName")
$FileYear = Val(Substr($FileDate,1,4))
$FileMonth = Val(Substr($FileDate,6,2))
$FileDay = Val(Substr($FileDate,9,2))
;=== Get this Year.
$NowYear = @YEAR
? "Test number 1, check which variables are set..."
? "==============================================="
? "FileDate is $FileDate"
? "FileYear is $FileYear"
? "FileMonth is $FileMonth"
? "FileDay is $FileDay"
? "NowYear is $NowYear"
? "FileName is $FileName"
Get $x
;=== First thing to compare is the years, depending on your
;=== wishes, this can speed up the process, since no further
;=== calculations is nesccessary for really old files.
;=== BEWARE of shiftings between years, a minimum of two is
;=== a must (of course depending on your $DelDayCount.)
$YearTotal = $NowYear - $FileYear
IF $YearTotal > 2
GOTO FILEDELETE
ENDIF
;=== Calculate the total number of days that differ between the
;=== file and todays date.
$YearDiff = $YearTotal * 365
$MonthDayDiff = $FileDay + ($FileMonth * 30)
$FileDiff = @YDAYNO + ($YearDiff - $MonthDayDiff)
;=== And here is the comparison.
IF $FileDiff > $DelDayCount
GOTO FILEDELETE
ENDIF
GOTO NEXTFILE
:FILEDELETE
? "Deleting... $FileName"
;DEL("$FileName")
:NEXTFILE
? ""
? "Test number 2, check which variables are set..."
? "==============================================="
? "YearTotal is $YearTotal"
? "YearDiff is $YearDiff"
? "MonthDayDiff is $$MonthDayDiff"
? "FileDiff is $FileDiff"
Get $x
;=== Get the next file, and do until there are no more files.
$FileName = Dir()
LOOP
I've been testing this with some files copied into C:\datetest, and the first file Dir() finds is "Key.ini", modified 1999-07-01 19:37, the script then generated the following output:
code:
Test number 1, check which varibles are set...
==============================================
FileDate is
FileYear is 0
FileMonth is 0
FileDay is 0
NowYear is 2001
FileName is Key.ini
Deleting... Key.iniTest number 2, check which varibles are set...
==============================================
YearTotal is 2001
YearDiff is $YearDiff
MonthDayDiff is $MonthDayDiff
FileDiff is $FileDiff
The script doesn't work with any file until it hits my copy of msdos.sys, then, all of the sudden, the script works well! (FileDate is 2000/11/23 11:30:28).
[This message has been edited by masken (edited 08 January 2001).]