SMove, secure file moving

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

SMove, secure file moving

Post 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()
SPAMINATOR NR.1
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: SMove, secure file moving

Post by Mistrel »

Isn't this the same thing as using xcopy with the /v (verify) switch? This is how I backup my data.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: SMove, secure file moving

Post by Rings »

no, this is moving files, not only copying .
SPAMINATOR NR.1
Post Reply