Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: UDF - Delete old TMP files
#DefineFunction DeleteoldTMPfiles(startdir,daysold) Terminate(DirExist(fromdir)==@false,"Eeep","Startdir directory does not exist") ;make sure we have a full path or a UNC starttest=strindex(startdir,":",0,@fwdscan) + (strsub(startdir,1,2)=="\\") Terminate(starttest==0,"Eeep","Full path must be specified for startDir") DirChange(startdir) ;clean up passed paramters just in case if strsub(startdir,strlen(startdir),1) != "\" then startdir=strcat(startdir,"\") ;check/delete files in this directory ;copy files in this directory list=FileItemize("*.tmp") count=ItemCount(list,@tab) now=TimeYmdHms() for xx=1 to count thisfile=ItemExtract(xx,list,@tab) thistime=FileTimeGetEx(thisfile,3) test=TimeDiffDays(now,thistime) if test >= daysold ErrorMode(@off) FileDelete(thisfile) ErrorMode(@cancel) endif next ;get list of subdirectories dirlist=DirItemize("*.*") count=ItemCount(dirlist,@tab) ;Preocess each subdirectory for xx=1 to count thisdir=ItemExtract(xx,dirlist,@tab) fulldir=strcat(startdir,thisdir,"\") DeleteoldTMPfiles(fulldir,daysold) next return #EndFunction DeleteoldTMPfiles("C:\",14) Message("","Done")
Article ID: W15749
File Created: 2004:10:20:13:09:34
Last Updated: 2004:10:20:13:09:34