Subj : .. To : All From : Robert Todd Date : Thu Dec 07 2000 01:53 am FORUM: (104) comp.lang.pascal.borland MSG#: 14133 FROM: NAT.MEAD@NTLWORLD.COM DATE: 22 Nov 2000, 12:11p TO: ALL SUBJECT: source - autodel { source - autodel.pas Autodel reads in a list of filenames/wildcards and deletes files based on that information. the list is a external file that looks like: ------ c:\scandisk.log c:\autoexec.0* c:\autoexec.bak c:\chk0*.chk ------ ofcource, the ---'s are not in the file.. it will delete any file matching the specified filespec(s), inc. hidden.system & readonly files. i have it in my autoexec to clear out the root of any crap and my temp dirs. and again.. i dont accept any responobility for your failure to understand this code (how fick are u?) Code^Bandit. } uses mainproc,crt,dos; const copyright = 'AutoDel v1.1 (c) 1994-2000 Code^Bandit'; var fn : file; flist : text; tmpstr : string; i : integer; do_kill : string; function trim(s:string):string; begin if s[1]=' ' then repeat delete(s,1,1); until (s[1] <> ' ') or (length(s) = 0); if s[length(s)]=' ' then repeat delete(s,length(s),1); until (s[length(s)] <> ' ') or (length(s)=0); trim:=s; end; function get_fname: string; var tstr : string; begin readln(flist, tstr); tstr:=trim(tstr); get_fname:=tstr; end; procedure kill_file(s : string); var dirinfo : searchrec; begin findfirst(s, archive+sysfile+readonly+hidden, dirinfo); while doserror = 0 do begin assign(fn, fdir(s)+dirinfo.name); SetFAttr(fn, archive); { Uh-oh } writeln('[DEL] ',fdir(s)+dirinfo.name); erase(fn); findnext(dirinfo); end; end; procedure doerror; begin writeln; writeln('Autodel needs 1 paramiter specifed on command line.'); writeln('it needs to know the location of AUTODEL.LST which contains'); writeln('the filespec it should delete. Autodel will erase any file,'); writeln('even hidden, system and read-only files.'); writeln('format of autodel.lst, example:'); writeln; writeln('filename.exe'); writeln('file*.bak'); writeln('c:\scandisk.log'); writeln; halt(98); end; begin assign(output,''); rewrite(output); writeln(copyright); if paramcount <> 1 then doerror; assign(flist, paramstr(1)); {$i-} reset(flist); {$i+} if ioresult <> 0 then begin rewrite(flist); writeln(flist,''); close(flist); writeln(paramstr(1),' not found - created new.'); halt(99); end; writeln(''); repeat tmpstr:=get_fname; if tmpstr <> '' then begin kill_file(tmpstr); end; until eof(flist); close(flist); writeln(''); end. .... Platinum Xpress & Wildcat!..... Nice!!!! --- Platinum Xpress/Win/WINServer v3.0pr5 * Origin: Fido/3407 - MS Online - msol.dtdns.net (1:3407/4) .