Jump to content

DirMove() bug? Only works with flag=1


shEiD
 Share

Recommended Posts

Hi, I just spent 2 hours looking for a bug in my script, until finally I realized, that the bug is in AutoIt's DirMove() itself, it seems...

Example:

Example()
Func Example()
    DirCreate('C:\DirMove.Test\Destination')
    DirCreate('C:\DirMove.Test\Flag.None')
    DirCreate('C:\DirMove.Test\Flag.0')
    DirCreate('C:\DirMove.Test\Flag.1')
    Sleep(1500)
    DirMove('C:\DirMove.Test\Flag.None', 'C:\DirMove.Test\Destination')
    DirMove('C:\DirMove.Test\Flag.0', 'C:\DirMove.Test\Destination', 0)
    DirMove('C:\DirMove.Test\Flag.1', 'C:\DirMove.Test\Destination', 1)
EndFunc  ;==>Example
Exit

The only folder that gets moved is Flag.1. No flag or flag=0 does not work and returns 0.

Please confirm.

Thanks in advance.

Edited by shEiD
Link to comment
Share on other sites

From the Helpfile:

Flag: 0 = (default) do not overwrite existing files

From your code:

DirCreate('C:\DirMove.Test\Destination')

DirCreate('C:\DirMove.Test\Flag.None')

DirCreate('C:\DirMove.Test\Flag.0')

DirCreate('C:\DirMove.Test\Flag.1')

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

@somdcomputerguy Huh? I don't get it, what did you mean by that? What it has to do with overwriting and creating folder (your qoute of my code).

There is no overwriting needed in the example.

Anyway, DirMove is pretty weird or f***ed up - even more bugs?:

Examples:

Example2()
Example3()

Func Example2()
    DirCreate('C:\DirMove.Test.2\Flag.1')
    FileWriteLine('C:\DirMove.Test.2\Flag.1\test.txt', 'test')
    Sleep(1500)
    DirMove('C:\DirMove.Test.2\Flag.1', 'C:\DirMove.Test.2\Destination', 1)
EndFunc  ;==>Example

Func Example3()
    DirCreate('C:\DirMove.Test.3\Destination')
    DirCreate('C:\DirMove.Test.3\Flag.1')
    FileWriteLine('C:\DirMove.Test.3\Flag.1\test.txt', 'test')
    Sleep(1500)
    DirMove('C:\DirMove.Test.3\Flag.1', 'C:\DirMove.Test.3\Destination', 1)
EndFunc  ;==>Example

Exit

Example 2: file gets moved to "C:\DirMove.Test.2\Destination" (what the hell?)

Example 3: file gets moved to "C:\DirMove.Test.3\Destination\Flag.1" (ok)

It seems, if destination directory does not exist, weird s**t happens ;)

Edit: nevermind, just read help file again, and I gather in the Example2 DirMove() behaves like DirRename (which is not present in AutoIt). Confusing... :)

But what with the flags 0/ no flag not working, I still don't get it...

Edited by shEiD
Link to comment
Share on other sites

You need to specify the full path you want to move the folder to, including the name you want the folder to have in the new location.

for example: DirMove("C:\SomeFolder\MoveFolder", "C:\SomeOtherFolder") would rename "MoveFolder" to "SomeOtherFolder" which is created in "C:\".

To Move the folder inside the other folder use:

DirMove("C:\SomeFolder\MoveFolder", "C:\SomeOtherFolder\MoveFolder")

Edit: Too late ;)

Edited by Tvern
Link to comment
Share on other sites

;)

@Tvern Thanks anyway

About example in the first post:

Help file for DirMove says:

[optional] this flag determines whether to overwrite files if they already exist

Or should I understand that DirMove does not overwrite folders if they exist aswell, not only files?

If this is the case then help file needs clarification.

Edited by shEiD
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...