Sign in to follow this  
Followers 0
birdofprey

DirMove refuses to work with subdirs ??? See code.

13 posts in this topic

#1 ·  Posted (edited)

So, take the last folder from the $curdir path, "C:\a\b\c\d" and put it into "D:\asdf\d". It only works into "D:\asdfd". Beats me why.

Here's the thing, I tried quoting, unquoting, variables, concrete strings, etc... I ended up seeing that it only works with "D:\asdf" the moment I add "\", and thus try to move to a subfolder, the game is over.

Case $msg[0] = $archbn ; Archive folder. (Someday will be available only on last file in a folder.)
            Global $movetoarch =  "D:\asdf\" & StringRight ($curdir, StringLen ($curdir) - StringInStr ($curdir, "\", 0, -2 ))
;~          $movetoarch = '"' & StringLeft ( $movetoarch, (StringLen ($movetoarch) - 1)) & '"'          
            $movetoarch = StringLeft ( $movetoarch, (StringLen ($movetoarch) - 1))
            $curdirt = StringLeft ( $curdir, (StringLen ($curdir) - 1))

            $errorr = DirMove ($curdirt, $movetoarch, 1)    
            ConsoleWrite ( "!-- " & " to " & $movetoarch  & " from "  & $curdirt & " error: " & $errorr & @LF)

It's not a trailing \ problem. ConsoleWrite shows this clearly. What am I doing wrong ??? Has there been problems with DirMove ? As you can see, I'm using an older version of autoit.

Thanks !

Edited by birdofprey

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Couple of things wrong uneeded Lines and ()

working

Case $msg[0] = $archbn ; Archive folder. (Someday will be available only on last file in a folder.)
    Global $movetoarch = "D:\asdf\" & StringRight($curdir, StringLen($curdir) - StringInStr($curdir, "\", 0, -1)); S
;~          $movetoarch = '"' & StringLeft ( $movetoarch, (StringLen ($movetoarch) - 1)) & '"'

    ;====================================== Totally uneeded
    ;$movetoarch = StringLeft($movetoarch,StringLen($movetoarch) - 1) ;-Extra () ?
    ;$curdirt = StringLeft ( $curdir,StringLen ($curdir) - 1);-Extra () ?
    ;=====================================
    $errorr = DirMove($curdir, $movetoarch, 1)
    ConsoleWrite("!-- " & " to " & $movetoarch & " from " & $curdir & " error: " & $errorr & @LF)

EDIT: BTW if you want only the last folder its -1 not -2 updating (unless $curdir = c:\test\double\test\ <-- then it is -2 )

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites

Couple of things wrong uneeded Lines and...

EDIT: BTW if you want only the last folder its -1 not -2 updating (unless $curdir = c:\test\double\test\ <-- then it is -2 )

Those uneeded lines are needed. I take the blame for naming a variable for a path, as dir, but, that -2 actually looks for the second last / so that I can cut out this part from D:\a\b\c\this\. After that, I'll take this and would like to put into into D:\asdf\this. The autoit helpfile says specifically that there are no trailing / allowed with dirmove, but because my original vars do contain a trailing / I guess I DO NEED THOSE EXTRA LINES.

What I can't quite explain is that if I replace the destination directory with this string,

$errorr = DirMove ($curdirt, "D:\a\b\c" , 1)

it does work !

$errorr = DirMove ($curdirt, "D:\a" , 1)

it DOESN'T !!! I just double checked. Took me hours to boil the problem down to this... Can someone explain what's going on ???

I'll try to compile on a different computer, I had situations where seemingly a reboot solved the problem...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Those uneeded lines are needed. I take the blame for naming a variable for a path, as dir, but, that -2 actually looks for the second last / so that I can cut out this part from D:\a\b\c\this\. After that, I'll take this and would like to put into into D:\asdf\this. The autoit helpfile says specifically that there are no trailing / allowed with dirmove, but because my original vars do contain a trailing / I guess I DO NEED THOSE EXTRA LINES.

Then the code above does work using -2 instead of -1 and the lines are still uneeded... I tried the script and it's working just fine on my comp, hard to replicate the issue on a larger scale.

Exactly how long is the variable? Char's ? Perhaps there is a limit error.

However this script works try it!

;example;
$curdir = 'c:\hello\new\test4\'

;Case $msg[0] = $archbn ; Archive folder. (Someday will be available only on last file in a folder.)
           Global $movetoarch =  "C:\Test\test2\test3\" & StringRight ($curdir, StringLen ($curdir) - StringInStr ($curdir, "\", 0, -2 )); S
;~          $movetoarch = '"' & StringLeft ( $movetoarch, (StringLen ($movetoarch) - 1)) & '"'


;====================================== Totally uneeded
            ;$movetoarch = StringLeft($movetoarch,StringLen($movetoarch) - 1) ;-Extra () ?
            ;$curdirt = StringLeft ( $curdir,StringLen ($curdir) - 1);-Extra () ?
;=====================================
           $errorr = DirMove ($curdir, $movetoarch, 1)
            ConsoleWrite ( "!-- " & " to " & $movetoarch  & " from "  & $curdir &" error: " & $errorr & @LF)

EDIT: PS the \ during DirMove does work

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

!-- to D:\b\a\ from D:\a\ error 0 - nothing happened.

!-- to E:\b\c\ from D:\c\ error 0 - This one moves from a partition to another. IT DOES move the folders contents, but it still returns 0 because D:\c\ is left in place. Same thing goes for: !-- to D:\a\b\c\ from E:\b\c\ error 0

But this, "!-- to D:\a\b2\c\ from D:\a\b\c\ error 0", doesn't move anything again !

All of the above is the result of your code in action. I've also upgraded to version 3.2.8.1, parts of my script isn't working properly, I even disabled the firewall.

Also, I replaced the destination directories with strings as mentioned in the previous post, because I have a feeling that despite the "double checking" of the results, I posted in a hurry, and got what's working and what not, the other way around. To my surprise... both work now.

!-- to D:\a\b2\c\ from D:\a\c\ error 1.

Problems like this seem to haunt me, as described in my other post, where after a lot of headache, I had to conclude that there's nothing wrong with the code, but every time I use hotkeys I have to face the upcoming "ms71-something.dll" error. From this perspective, I'm sorry to say, I'm considering rewriting everything in another language... so I'd really like to know if I'm doing something dumb or if it's my XP or I don't know... I just wanted to do some Quick and Dirty patching, and here I am... ;):evil:

I'll go and check on another computer now... could this be a hardware issue ???

Any feedback appreciated ! Thanks lordicast !

Edited by birdofprey

Share this post


Link to post
Share on other sites

Why are you using a AutoIt from the dark ages if you're running windows XP?

Did you even check the basic things, like if you can move the files manually?

And finally, what the hell is "ms71-something.dll" supposed to be? Are you saying it happens with HotKeySet()? Then it's time you re-install Windows.

Share this post


Link to post
Share on other sites

Taken from the DirMove() documentation,

source_dir : Path of the source directory (with no trailing backslash). e.g. "C:\Path1"

dest_dir : Path of the destination dir (with no trailing backslash). e.g. "C:\Path_Copy"

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Why are you using a AutoIt from the dark ages if you're running windows XP?

Did you even check the basic things, like if you can move the files manually?

And finally, what the hell is "ms71-something.dll" supposed to be? Are you saying it happens with HotKeySet()? Then it's time you re-install Windows.

I'm using an older version, because I don't want to change half of my code, and walk myself through all the changes, just to add some functionality. This was supposed to be a quick and dirty patching only. (Of a program I wrote about 3 years ago..) But I understand what you are saying. On the other hand, DirMove not working was a hack of a surprise...

The files move from time to time as you can see. I am sure I can move them manually.

Regarding the hotkeys - I meant modifier keys, sorry ;) (I hope this only shows my frustration), I'm cliking a button while holding control, so that instead of the window for selecting a new folder poping up, it loads the last loaded directory. Unfortunately, if I dare doing this I face the error - every time a new file in the row takes its turn on being opened. I don't see a connection.

I don't think I need to reinstall XP either cause I've done a sfc /scannow, just a while ago.

Thanks for trying :evil:

Edited by birdofprey

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Taken from the DirMove() documentation,

source_dir : Path of the source directory (with no trailing backslash). e.g. "C:\Path1"

dest_dir : Path of the destination dir (with no trailing backslash). e.g. "C:\Path_Copy"

Exactly that's why I had those 2 "uneeded" lines... and as you can see, THINGS DO WORK WITHOUT THEM. But just to make sure: I've put the lines back and tried to move files from a partition to another "!-- to E:\a\b3\c from D:\a\b\c\ error 0". Despite this, the files were MOVED, leaving an empty directory behind. So, now we now it's the trailing /-s fault.

Thanks Mobius ! It seems we stick to the principle of uncertainty and chaos for now ;):evil:

Edited by birdofprey

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Exactly that's why I had those 2 "uneeded" lines... and as you can see, IT DOES WORK WITH THEM.

I've put the lines back and tried to: !-- to E:\a\b3\c from D:\a\b\c\ error 0. Despite this, the files were MOVED, leaving an empty directory behind.

Thanks Mobius ! It seems we stick to the principle of uncertainty and chaos for now ;):evil:

well according the version I have 3,3,0,0 it does work. Have you even tried it? I had 5 text files in test4 folder all of them copied even if it says no \ it worked call it a miracle.

edit: console info !-- to C:\Test\test2\test3\test4\ from c:\hello\new\test4\ error: 0

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites

:evil: Whether it works or not (sporadically or not) adding a trailing slash when implicitly told not to is just plain ;).

Nothing wrong with Chaos (love it in fact) but...

I'm using an older version, because I don't want to change half of my code, and walk myself through all the changes, just to add some functionality.

You will get used to it eventually its part of the job. :evil:

Share this post


Link to post
Share on other sites

well according the version I have 3,3,0,0 it does work. Have you even tried it? I had 5 text files in test4 folder all of them copied even if it says no \ it worked call it a miracle.

edit: console info !-- to C:\Test\test2\test3\test4\ from c:\hello\new\test4\ error: 0

Failure: Returns 0 if there is an error moving the directory

Whose console info is that ? It returns 0 even when it works ? I'd call this a miracle indeed. ;)

I guess it's irrelevant though :evil: You see, I tried 3 different versions of autoit, I'm seriously considering hardware failure.

Share this post


Link to post
Share on other sites

:evil: Whether it works or not (sporadically or not) adding a trailing slash when implicitly told not to is just plain ;).

Agreed. But I see a geek in this picture: :evil: and I don't care what it's called.

Nothing wrong with Chaos (love it in fact) but...

You will get used to it eventually its part of the job. :)

I agree with Chaos as in challenge, or diversity, or unexpected. I don't see what's to love in noise for example... and something's really bugging me about DirMove too right now...

Part of the job could be also: considering XUL... or... or... or....

I'm already stuck with that other error I can't get rid of so I'm afraid I don't see it worthwhile... despite the fun I had with autoit. :idea:

Share this post


Link to post
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
Sign in to follow this  
Followers 0