I'm making a script to archive and mail some logfiles, it also should delete files older then x days...

I've got two methods and both don't work:

Kix based:
$curryear=substr(@DATE,1,4)
$currmonth=substr(@DATE,6,2)
$currday=substr(@DATE,9,2)
$currdays=((365*$curryear)+((365*$currmonth)/12)+$currday)
$filename=dir("@SCRIPTDIR\*.*")
while $filename<>“” and @ERROR=0
$filedate=getfiletime($filename)
$fileyear=substr($filedate,1,4)
$filemonth=substr($filedate,6,2)
$fileday=substr($filedate,9,2)
$filedays=((365*$fileyear)+((365*$filemonth)/12)+$fileday)
$fileage=$currdays-$filedays
? "$filename is $fileage days old"
$filename=dir()
loop

This code works but not for all files, on a lot of files this gives 00-00-0000 as result. Why?

Also I tried forfiles:
shell "@SCRIPTDIR\forfiles -p$savepath -d-$savedays -v -c""%comspec% -C echo @FILE"""

All variables work, but forfiles doesn't echo files older then $savedays.

forfiles error:
----- DIRECTORY : d:\temp\p-logger\logs
can't execute (error 2)
1 file(s) processed
1 total file(s) processed
C:\WINDOWS\system32\cmd.exe -C echo @FILE

Hope you can help me...