Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site whuxlm.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!whuxlm!jph From: jph@whuxlm.UUCP (Holtman Jim) Newsgroups: net.micro.pc Subject: Re: DOS dir rename solution Message-ID: <802@whuxlm.UUCP> Date: Thu, 1-Aug-85 17:53:32 EDT Article-I.D.: whuxlm.802 Posted: Thu Aug 1 17:53:32 1985 Date-Received: Sat, 3-Aug-85 02:09:00 EDT References: <21900064@uiucuxc> Organization: AT&T Bell Laboratories, Whippany Lines: 70 > > Previously there have been requests for a method for changing directory > names in PC DOS without going through the pain of copying the contents > the old directory into a newly named one and then destroying the old one. > An easy-to-implement solution is given in PC Magazine, August 6, 1985 on > page 222. I tried it and it worked! *** REPLACE THIS LINE WITH YOUR MESSAGE *** Here is a TURBO PASCAL program that will rename any file, including a directory. I uses the DOS call 17H to perform the function. ========================= program rename; {rename files or directories} type regset = record case integer of 1: ( ax,bx,cx,dx,bp,si,di,ds,es,flags : integer); 2: ( al,ah,bl,bh,cl,ch,dl,dh : byte); end; var params : regset; fcb : array[-7..37] of byte; {Extended FCB} file_name : string[20]; i : integer; begin fcb[-7] := $FF; {setup Extended FCB} fcb[-1] := $16; {match on anything} with params do begin write('Old File Name: '); readln(file_name); file_name := file_name + ' '; {terminate to stop parse} ax := $2901; {parse the filename} ds := seg(file_name[1]); si := ofs(file_name[1]); es := seg(fcb[0]); di := ofs(fcb[0]); msdos(params); if al <> 0 then begin writeln(^G'invalid file name'); halt; end; write('New File Name: '); readln(file_name); file_name := file_name + ' '; ax := $2903; {parse the file name} ds := seg(file_name[1]); si := ofs(file_name[1]); es := seg(fcb[$10]); di := ofs(fcb[$10]); msdos(params); if al <> 0 then begin writeln(^G'invalid file name'); halt; end; ah := $17; {rename call} ds := seg(fcb[-7]); {use the Extended FCB} dx := ofs(fcb[-7]); msdos(params); if al <> 0 then writeln(^G'Rename Unsuccessful!!') else writeln('Done'); end; end.