ALIENQuake Posted March 31, 2016 Posted March 31, 2016 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.
AutoBert Posted March 31, 2016 Posted March 31, 2016 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.
ALIENQuake Posted March 31, 2016 Author Posted March 31, 2016 You reply is not helpful, is there any replacement for DirMove function which won't have such drawback?
JohnOne Posted March 31, 2016 Posted March 31, 2016 Reply is valid. What behaviour is it that you want? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
ALIENQuake Posted April 1, 2016 Author Posted April 1, 2016 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.
Developers Jos Posted April 1, 2016 Developers Posted April 1, 2016 So what is it you need the script to do then and what is so dramatically devastating for you currently? 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.
ALIENQuake Posted April 1, 2016 Author Posted April 1, 2016 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.
Developers Jos Posted April 1, 2016 Developers Posted April 1, 2016 So what is actually happening when you provide the override flag 1? 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.
JohnOne Posted April 1, 2016 Posted April 1, 2016 So.... Func _DirMove($Source, $Destination, $Flag) ;; Pseudo code If Destination exists And flag is Set Then Remove destination Dir Move source dir Return EndIf Move source dir EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
ALIENQuake Posted April 1, 2016 Author Posted April 1, 2016 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.
Developers Jos Posted April 1, 2016 Developers Posted April 1, 2016 1 hour ago, Jos said: So what is actually happening when you provide the override flag 1? 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.
ALIENQuake Posted April 1, 2016 Author Posted April 1, 2016 The " source directory will be moved inside the destination." so instead of having: Source: D:\A\* Dest: E:\A\* i endup with E:\A\A\*
Developers Jos Posted April 1, 2016 Developers Posted April 1, 2016 Is that the behavior you have seen or assuming due to the text in the helpfile? 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.
ALIENQuake Posted April 1, 2016 Author Posted April 1, 2016 I've tested it and this behavior is the reason of this thread.
Trong Posted April 1, 2016 Posted April 1, 2016 #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 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
Developers Jos Posted April 1, 2016 Developers Posted April 1, 2016 (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 April 1, 2016 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.
ALIENQuake Posted April 2, 2016 Author Posted April 2, 2016 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?
AutoBert Posted April 2, 2016 Posted April 2, 2016 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.
ALIENQuake Posted April 2, 2016 Author Posted April 2, 2016 (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 April 2, 2016 by ALIENQuake
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now