The replacement function for DirMove()
Func _DirMove($SourceDir, $DestDir, $flag = 0)
Local $Show_Debug = 1, $SourceDir_Exists = FileExists($SourceDir)
If $Show_Debug Then ConsoleWrite("> Move folder '" & $SourceDir & "' [To> '" & $DestDir & "'" & @CRLF)
If ($SourceDir_Exists < 1) Then
If $Show_Debug Then ConsoleWrite("! ERROR - The source directory does not exist at: " & $SourceDir & @CRLF)
Return SetError(1, -1, 0)
EndIf
Local $file_Move = '', $file_Moved = 0, $Move_Error = 0
$SourceDir = StringReplace($SourceDir, "/", '\')
$DestDir = StringReplace($DestDir, "/", '\')
If StringRight($SourceDir, 1) == '\' Then $SourceDir = StringTrimRight($SourceDir, 1)
If StringRight($DestDir, 1) == '\' Then $DestDir = StringTrimRight($DestDir, 1)
If Not FileExists($DestDir) Then
If $Show_Debug Then ConsoleWrite("> Found folder: " & $SourceDir & @CRLF)
If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF)
DirCopy($SourceDir, $DestDir, $flag)
Else
If $Show_Debug Then ConsoleWrite("- Getting a list of files... " & @CRLF)
Local $aFileList = _FileListToArrayRec($SourceDir & "\", "*", 1, 1, 1, 1)
If (@error < 1) And IsArray($aFileList) Then
If $Show_Debug Then ConsoleWrite("> Found files in: " & $SourceDir & @CRLF)
If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF)
For $I = 1 To $aFileList[0]
$file_Move = $SourceDir & "\" & $aFileList[$I]
$SourceDir_Exists = FileExists($file_Move)
$file_Moved = FileMove($file_Move, $DestDir & "\" & $aFileList[$I], $flag < 1 ? 0 : 1 + 8)
$Move_Error = @error
If $Show_Debug Then ConsoleWrite("- Move file: " & $file_Move & " [" & $SourceDir_Exists & "] To> " & $DestDir & "\" & $aFileList[$I] & " [" & FileExists($DestDir & "\" & $aFileList[$I]) & "] > [Moved:" & $file_Moved & "-E:" & $Move_Error & "] " & (FileExists($file_Move) ? "Error" : "OK") & @CRLF)
$file_Move = ''
$SourceDir_Exists = 0
$file_Moved = 0
Next
Else
If $Show_Debug Then ConsoleWrite("! No files found at: " & $SourceDir & @CRLF)
EndIf
EndIf
If $Show_Debug Then
If FileExists($DestDir) Then ConsoleWrite("> Copied " & $SourceDir & " [To> " & $DestDir & @CRLF)
EndIf
If $Show_Debug Then ConsoleWrite("- Removing the source folder: " & $SourceDir & @CRLF)
If FileExists($SourceDir) Then
DirRemove($SourceDir, $flag)
If FileExists($SourceDir) Then
FileSetAttrib($SourceDir, "-RASH", $flag)
DirRemove($SourceDir)
If FileExists($SourceDir) And $flag Then
RunWait(@ComSpec & ' /c takeown /f "' & $SourceDir & '" /r /d y', '', @SW_HIDE)
RunWait(@ComSpec & ' /c Echo y|icacls "' & $SourceDir & '" /grant EveryOne:F /t /q', '', @SW_HIDE)
RunWait(@ComSpec & ' /c RD /s /q "' & $SourceDir & '"', '', @SW_HIDE)
DirRemove($SourceDir)
EndIf
EndIf
EndIf
If FileExists($SourceDir) Then
If $Show_Debug Then ConsoleWrite("! FAILURE ! Folder " & $SourceDir & " has not been moved to: " & $DestDir & @CRLF)
Return SetError(1, 0, 0)
Else
If $Show_Debug Then ConsoleWrite("+ SUCCESS ! Folder " & $SourceDir & " has been moved to: " & $DestDir & @CRLF)
Return SetError(0, 0, 1)
EndIf
EndFunc ;==>_DirMove