Hi,compare file date/time
Currently I use this shell command: (COMMAND "SHELL" "DEL /S \"C:\\Temp_Acad\\Backup\\*.bak\" /Q")within my acaddoc.lsp to delete ALL bak files once a day. BUT how can this be adapted to only delete bak files older than 1 day?
Any help or guidance with this would be much appreciated.
Many thanks in advance, Robbo.
(vl-file-systime "d:\\txt.lsp")
with system time:; =========================================================================================== ;
; Zwraca date/czas systemowa(y) / Return system date/time ;
; Format [STR] - ;
; ----- Data / Date ----- | ---- Czas / Time ---- ;
; D -> 5 | H -> 4 ;
; DD -> 05 | HH -> 04 ;
; DDD -> Sat | MM -> 53 ;
; DDDD -> Saturday | SS -> 17 ;
; M -> 9 | MSEC -> 506 ;
; MO -> 09 | AM/PM -> AM or PM ;
; MON -> Sep | am/pm -> am or pm ;
; MONTH -> September | A/P -> A or P ;
; YY -> 89 | a/p -> a or p ;
; YYYY -> 1989 | ;
; ------------------------------------------------------------------------------------------- ;
; (cd:SYS_GetDateTime "DDD\",\" DD MON YYYY - H:MMam/pm") ;
; =========================================================================================== ;
(defun cd:SYS_GetDateTime (Format)
(menucmd (strcat "m=$(edtime,$(getvar,DATE)," Format ")"))
)
Thank you kruuger for your prompt reply.
I am not sure how to implement this with my acaddoc.lsp being new to lisp.
Cheers, Robbo.
(defun _BAK (Name / fl st)
(setq fl (vl-file-systime Name)
st (read (strcat "(" (cd:SYS_GetDateTime "YYYY M DD") ")"))
)
(and
(eq (car fl) (car st))
(eq (cadr fl) (cadr st))
(< (- (caddr st) (cadddr fl)) 1)
)
)
(if (_bak "file.txt")
... file ...
... delete ...
)
k.