I am working on a similar script. I have several thousand audio recordings. They are named with the following format YYYYMMDD-HHMMSS.wma The letters being:YearMonthDay-HourMinuteSecond. It is a long story, but the files are created on little hand held recorders, and the date and time info from these little recorders is extremely unreliable. I wrote a script that pulls the files from the recorders and puts them on a network share while also renaming them to the current date and time as described above. Now I need a script that purges any file more than 90 days old. I can use DateMath UDF to get the date, split and join it into the correct format and then issue a simple del statement such as: "Del /S C:\YYYYMMDD*". The problem is there is no /S switch in the Kix Del command, only in DOS. I can just send the command to a DOS shell, but that seems clumsy. Isn't there a better way?

Here is what I have so far.

Code:
 
Break On
$resultdate = Datemath(@DATE,-91)
$Date = Join(Split($resultdate,'/'),"")
;Del /S C:\YYYYMMDD*     What to do here???



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;Functions
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Function DateMath($ExpD1,$ExpD2)
    ; Author: ScriptLogic Corporation
    ; if both parameters are dates (yyyy/mm/dd), a positive
    ; integer indicating the days between the two dates will be returned.
    ; if the first is a date (yyyy/mm/dd) and the second is an integer
    ; (number of days), a new date will be returned.
    ; UDF dependencies: SerialDate, abs
    Select
    Case InStr($ExpD1,'/') And InStr($ExpD2,'/')
        ; two date passed - return daysbetween integer
        $DateMath=serialdate($ExpD1)-serialdate($ExpD2)
        If $DateMath<0
            $DateMath=$DateMath*-1
        EndIf
    Case InStr($ExpD1,'/') And 1-InStr($ExpD2,'/')
        ; date and a number passed - return date
        $ExpD2=0+$ExpD2
        $Datemath=serialdate(serialdate($ExpD1)+$ExpD2)
    Case 1 ; incorrect parameters passed
    EndSelect
EndFunction

Function SerialDate($ExpD)
    ; Author: ScriptLogic Corporation
    ; parameter ($ExpD) must be a date (in the form of yyyy/mm/dd)
    ; or an integer previously derived by this function.
    ; if passed a date, it returns an integer.
    ; If passed an integer, it returns the date.
    ; Integers can be used for general-purpose math computations on dates
    ; and then converted back to dates by calling this function again.
    ; Algorithms were obtained from: http://www.capecod.net/~pbaum/date/date0.htm 
    Dim $z,$h,$a,$b,$c,$y,$m,$d
    If InStr($ExpD,'/') ; date passed
        $y=Val(SubStr($ExpD,1,4))
        $m=Val(SubStr($ExpD,6,2))
        $d=Val(SubStr($ExpD,9,2))
        If $m<3
            $m=$m+12
            $y=$y-1
        EndIf
        ; return an integer
        $SerialDate=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306
    Else ; integer passed
        $z=0+$ExpD+306 ; cast numeric
        $h=100*$z-25
        $a=$h/3652425
        $b=$a-$a/4
        $y=(100*$b+$h)/36525
        $c=$b+$z-365*$y-$y/4
        $m=(5*$c+456)/153
        $d=$c-(153*$m-457)/5
        If $m>12
            $y=$y+1
            $m=$m-12
        EndIf
        $m=Right('0'+$m,2)
        $d=Right('0'+$d,2)
        ; return a string date
        $SerialDate=''+$y+'/'+$m+'/'+$d
    EndIf  
EndFunction