You should be able to get some ideas from this:

Requires:
MAILER()
LOGGER()
DATECALC()
WSHPIPE()

Code:

CLS
BREAK ON
$log=@scriptdir+'\Profileremove.csv'
IF EXIST($log) DEL $log ENDIF
$date=split(@date,'/')[1]+'/'+split(@date,'/')[2]+'/'+split(@date,'/')[0]
$logdata='Run date/time:'+$date+' '+@time+@crlf
$logdata=$logdata+'Days ago,Location,Error Code'+@crlf+'-------------------'
LOGGER($log,$logdata+@crlf)

FOR EACH $i IN Split('01 02 03')
$loc='\\citrixserver'+$i+'\admin$$\profiles\'
$rc=WshPipe('%comspec% /c dir '+$loc+'*.*',1)
FOR EACH $line IN $rc
IF NOT instr($line, 'File Not Found')
;?$line
; -- Convert to American Dates from European format
;?$dtchk
$name=split($line)[17]
$dtchk=split(split($line)[0],'/')[2]+'/'+split(split($line)[0],'/')[0]+'/'+split(split($line)[0],'/')[1]
$dt=DATECALC($dtchk,@date)
IF val($dt)>2 AND len($name)>3 AND $name<>'All Users' AND $name<>'DEFAULT'
;IF len($name)>3 AND $name<>'All Users' AND $name<>'DEFAULT'
SHELL '%COMSPEC% /C RD /S /Q '+chr(34)+$loc+'\'+$name+chr(34)
If @error<>$err=1 ELSE $err=0 ENDIF
$logdata=''+$dt+','+$loc+$name+','+$err
LOGGER($log,$logdata+@crlf)
ENDIF
ENDIF
NEXT
NEXT
MAILER('user1@@company.com,user2@@company.com',,,$log)



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's