Jump to content

Recommended Posts

Posted

Hi,

from the DirMove page we have:

Quote

If the source and destination are on different volumes or UNC paths are used then a copy/delete operation will be performed rather than a move.

If the destination already exists and the overwrite flag is specified then the source directory will be moved inside the destination.

I'm facing exactly the same issue and I need a simplest way to fix it. Could somebody take look at this code:

Func _Extract_MoveMod($p_Dir)
    Local $Success=0
    $Files=_FileSearch($g_GameDir & '\' & $p_Dir, '*')
    For $f=1 to $Files[0]
        If StringInStr(FileGetAttrib($g_GameDir & '\' & $p_Dir & '\' & $Files[$f]), "D") Then
            $Success = DirMove($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir, 1)
        Else
            $Success = FileMove($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir & '\', 1)
        EndIf
        If $Success = 0 Then Return 0
    Next
    $Success = DirRemove($g_GameDir & '\' & $p_Dir, 1)
    Return $Success
EndFunc   ;==>_Extract_MoveMod

and tell me how I can fix this inside that function?

P.S. Why DirMove act such way is beyond my reason, especially as default and there is no flag to change it.

Posted

The example suggest DirMove with all inside sourcedir, Filemove and DirRemove in your func must throw errors because path doesn't exist (it's already moved).

Just try example and you will know how to short your function and also geting a runable function.

 

Posted

I want an replacement for DirMove function which won't act as it's described in remarks: If the destination already exists and the overwrite flag is specified then the source directory will be moved inside the destination.

It's absoluty devastating for my script logic. It act differently from everything I've used so far.

Posted

When I've move directory and the designation location already has the same directory and the overwrite flag is enables, I've expect that all files would be overwritten. That's what I need because i'm replacing old files with new version of files by moving them from subfolder.

Posted

I cannot remove whole Destination folder because there are files which aren't present inside source folder so I've on;y updating files which were actually changed.

Posted
#include <File.au3>

;Global $g_GameDir = @ScriptDir & "\GameDir"
;Global $p_Dir = "TestDir"

;ConsoleWrite(_Extract_MoveMod($p_Dir) & @CRLF)

Func _Extract_MoveMod($p_Dir)
    Local $Success = 0, $Error = 0
    Local $Files = _FileListToArrayRec($g_GameDir & '\' & $p_Dir, '*', 0, 1, 1, 1)
    For $f = 1 To UBound($Files) - 1
        ConsoleWrite($Files[$f] & @CRLF)
        If StringInStr(FileGetAttrib($g_GameDir & '\' & $p_Dir & '\' & $Files[$f]), "D") Then
            $Success = DirCopy($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir & '\' & $Files[$f], 1)
        Else
            $Success = FileCopy($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir & '\' & $Files[$f], 1)
        EndIf
        If $Success = 0 Then $Error += 1
    Next
    If ($Error == 0) Then Return (DirRemove($g_GameDir & '\' & $p_Dir, 1) <> 0)
    Return SetError(1, $Error, 0)
EndFunc   ;==>_Extract_MoveMod

 

Regards,
 

  • Developers
Posted (edited)

Have tried it with this syntax and does the same happen?:

DirMove("D:\A","E:",1)

Jos

Ps to others: Could you guys simply stop for a moment with all the alternatives and none related posts so we can stick with the reported issue? ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Ok, I've almost got it to work:

1. Included new function code
2. Got errors about missing functions > add every required/missing file, finally new function is executed
3. Got another error regarding array.au3:

Func _ArrayAdd(ByRef $aArray, $vValue, $iStart = 0, $sDelim_Item = "|", $sDelim_Row = @CRLF, $iForce = $ARRAYFILL_FORCE_DEFAULT)

    If $iStart = Default Then $iStart = 0
    If $sDelim_Item = Default Then $sDelim_Item = "|"
    If $sDelim_Row = Default Then $sDelim_Row = @CRLF
    If $iForce = Default Then $iForce = $ARRAYFILL_FORCE_DEFAULT
    If Not IsArray($aArray) Then Return SetError(1, 0, -1)
    Local $iDim_1 = UBound($aArray, $UBOUND_ROWS)
    Local $hDataType = 0
    Switch $iForce
        Case $ARRAYFILL_FORCE_INT
            $hDataType = Int
        Case $ARRAYFILL_FORCE_NUMBER
            $hDataType = Number
        Case $ARRAYFILL_FORCE_PTR
            $hDataType = Ptr
        Case $ARRAYFILL_FORCE_HWND
            $hDataType = Hwnd
        Case $ARRAYFILL_FORCE_STRING
            $hDataType = String
    EndSwitch

Line 84:

Quote

---------------------------
AutoIt Error
---------------------------
Line 84  (File "D:\EET-BWS\BWS\BiG World Setup\Includes\Array.au3"):

$hDataType = Int
$hDataType = Int^ ERROR

Error: Missing separator character after keyword.
---------------------------
OK   
---------------------------
 

and the reason is - I've using old AutoIt.exe 3.2.12.1 Please don't kill me when I say that I cannot update au3 version.  It would require rewriting 900KB of the code. Is there any way of fixing such bug without need to update AutoIt?
 

Posted
1 hour ago, ALIENQuake said:

and the reason is - I've using old AutoIt.exe 3.2.12.1 Please don't kill me when I say that I cannot update au3 version.

I think you used wrong path in dest, also i think you never tested (with installed 3.3.10.0 or above) the example DirMove in helpfile.

The actual error is caused using no Parameters for func int, it maybe caused by corrupting (wrong editing) of your array.au3.

I'm working with AutoIt since February 2008 your used version was already outdated at that time. Not updating to actaul stable is like Robison Crusoe living on a island.

Posted (edited)

I've not edited Array.au3 but I've taken it from newest AutoIt version. I think that the best is to avoid using "_FileListToArrayRec" function in Trong example. Then I wouldn't need Array.au3

Or ... I can just take this part of the code from Trong:

$Success = DirCopy($g_GameDir & '\' & $p_Dir & '\' & $Files[$f], $g_GameDir & '\' & $Files[$f], 1)

and replace the corresponding line in my code. Initial testing shows it works as expected. So adding "& '\' & $Files[$f]" to DirMove seems fixed it. I will do some more testing but already want to thanks everyone involving.

Edited by ALIENQuake

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...