beaucham@uiucuxc.Uiuc.ARPA (07/31/85)
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!
jph@whuxlm.UUCP (Holtman Jim) (08/02/85)
> > 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.