Page 1 of 1

SMove, secure file moving

Posted: Tue Dec 08, 2009 10:55 am
by Rings
If you wanna move files secure from one drive to another,
this code becomes handy.
It doesn't handle recursive directorys,
use RoboCopy for that.

Code: Select all

OpenConsole()
Source.s=ProgramParameter(0)
Destination.s=ProgramParameter(1)
PrintN("SMove by S.Rings,(c) 2009 ")
PrintN("-------------------------------------")
PrintN("secure move " + Source + " To " +Destination )
If Len(Source)=0 Or Len(Destination)=0 
 PrintN("Paramter ? xmove.exe SourceDirectory DestinationDirectory")
 CloseConsole()
 End
EndIf 

If Right(Source,1)="\" 
 Source=Left(Source,Len(Source)-1)
EndIf
If Right(Destination,1)="\" 
 Destination=Left(Destination,Len(Destination)-1)
EndIf
 
If ExamineDirectory(0, Source, "*.*") 
  While NextDirectoryEntry(0)
    Filename.s= DirectoryEntryName(0)
    If Filename<>"." And Filename<>".." 
      SFile.s=Source + "\" + Filename 
      DFile.s=Destination+"\"+Filename
      PrintN("Copy...." + Filename)
      Result=CopyFile(SFile,DFile)
      ;Debug Result
      If Result=1  
       MD1.s=MD5FileFingerprint(SFile)
       MD2.s=MD5FileFingerprint(DFile)
       ;Debug MD1
       ;Debug MD2
       If MD1=MD2  
        PrintN("Copy OK, Delete Source..")
        DeleteFile (SFile)
       EndIf
      Else
       PrintN("FAILED Copying "+Filename+ " to " +Destination) 
      EndIf
    EndIf 
  
  Wend
  FinishDirectory(0)
EndIf
CloseConsole()

Re: SMove, secure file moving

Posted: Tue Dec 08, 2009 11:33 am
by Mistrel
Isn't this the same thing as using xcopy with the /v (verify) switch? This is how I backup my data.

Re: SMove, secure file moving

Posted: Tue Dec 08, 2009 1:22 pm
by Rings
no, this is moving files, not only copying .