[comp.os.msdos.misc] how to move files

amb43790@uxa.cso.uiuc.edu (Anthony M Brummett) (03/14/91)

  Someone wanted to move files across directories without having to copy and
then delete.  Here's the solution:
For anyone with assembly language or any language which allows msdos functions
(INT 21h), they can write a program which uses one function call.
In assembly language:
    mov ah,056h     ;msdos function 56
    mov bx,segment oldname ;segment of pointer to old full path and name
    mov ds,bx       ;transfer to ds
    mov bx,segment newname ;segment of pointer to new full path and name
    mov es,bx       ;transfer to es
    mov dx,offset oldname  ;offset of pointer to old pathname
    mov di,offset newname  ;offset of pointer to new pathname
    int 021h
In Turbo pascal:
    uses dos;
    procedure filemove(old,new:string);
      var regs:registers;
      begin
        with regs do begin
          ah:=$56;
          ds:=seg(@old);
          es:=seg(@new);
          dx:=ofs(@old);
          di:=ofs(@new);
         end;{with regs}
         msdos(regs);
       end;{procedure}
Of course, these have no error recovery recovery routines and the code was 
written from memory with help from "Using Assembly Language" by Allen L. 
Wyatt.
BTW here's part of the documentation from the book:
  "Because the directory paths may differ, you can renamefiles across
    directories.  The only restriction is that both files must reside on the
    same drive."

Hope this helps.!

Antoine----------------anb43790@uxa.cso.uiuc.edu