Jump to content

DirMove not working


Recommended Posts

  • Moderators

NicePerson,

Works fine for me. Can you rename the folder manually? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I can think of a few reasons, in order from most, to least probable:

Is this script in a folder? There seems to be a bug with @ScriptDir where it will add a trailing "\" when it is run from the root of a drive, while it doesn't when it is in a folder. This can result in invalid filepaths.

Try this to see if the filepaths are correct.

ConsoleWrite(@ScriptDir&"\New Folder" & @CRLF & @ScriptDir & "\1-36-26 PM, 29 March, 2011" & @CRLF)

Try adding #RequireAdmin to your script, so you will have the proper rights to change the folder.

Just to make sure it's not a problem with the name. (path being too long for instance) try renaming to something simple to see if that works.

I had another suggestion, but I forgot it while writing this. :)

Link to comment
Share on other sites

Path seems to be correct:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "E:\AutoIt\DirMove.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams  
+>15:51:08 Starting AutoIt3Wrapper v.2.0.1.24   Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 3  CPU:X86 OS:X86)
>Running AU3Check (1.54.19.0)  from:C:\Program Files\AutoIt3
+>15:51:08 AU3Check ended.rc:0
>Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "E:\AutoIt\DirMove.au3" 
E:\AutoIt\New Folder
E:\AutoIt\1-36-26 PM, 29 March, 2011
+>15:51:09 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 3.462

I also tried #RequireAdmin but not worked..

Link to comment
Share on other sites

Then I don't know, unless it's something silly, like (a file in) the folder being in use, a folder with the destination name already existing, or an incorrect source path, I wouldn't know what could cause this to fail.

A test on my machine with the exect same path worked flawlessly.

Link to comment
Share on other sites

Another possibility ..

You cannot move or rename a folder, if a file is in use from that same folder.

- edit-

oops, Tvern said it too.

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

If you want to continue receiving help around here I would advice you to edit your last post to something less hot headed. Posts like that are not appreciated. Try and be the NicePerson you claim to be.

There is nothing wrong with DirMove() so it has to be one of the access permission issues on your PC that other have suggested.

Run this and post the output.

$result = DirCreate(@ScriptDir&"\New Folder")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' &  $result& @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

$result = DirMove(@ScriptDir&"\New Folder", @ScriptDir&"\1-36-26 PM, 29 March, 2011",1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') :  $result= ' &  $result& @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

$result = FileExists (@ScriptDir&"\1-36-26 PM, 29 March, 2011")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

  • 5 months later...

If you want to continue receiving help around here I would advice you to edit your last post to something less hot headed. Posts like that are not appreciated. Try and be the NicePerson you claim to be.

There is nothing wrong with DirMove() so it has to be one of the access permission issues on your PC that other have suggested.

Run this and post the output.

$result = DirCreate(@ScriptDir&"\New Folder")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' &  $result& @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
 
$result = DirMove(@ScriptDir&"\New Folder", @ScriptDir&"\1-36-26 PM, 29 March, 2011",1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') :  $result= ' &  $result& @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
 
$result = FileExists (@ScriptDir&"\1-36-26 PM, 29 March, 2011")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Hi,

I have to say that there definitly a bug in dirmove..

Running that give these return :

@@ Debug(55) : $result = 1

>Error code: 0

@@ Debug(58) : $result= 1

>Error code: 0

@@ Debug(61) : $result = 1

>Error code: 0

Thats normal..

But running it multiple time give this result in folder:

1-36-26 PM, 29 March, 2011\New Folder\New Folder

(The last "New Folder" should not exist right !?!)

is there something I dont understand ??

Edited by SilentBob999
Link to comment
Share on other sites

What's happening is that it's moving "New Folder" into the "1-36-26 PM, 29 March, 2011" folder, because that's what the code is telling it to do. The first time you ran it, that folder didn't exist, so it renamed "New Folder" to "1-36-26 PM, 29 March, 2011", the second time, it sees the "1-36-26 PM, 29 March, 2011" folder and moves "New Folder" into it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What's happening is that it's moving "New Folder" into the "1-36-26 PM, 29 March, 2011" folder, because that's what the code is telling it to do. The first time you ran it, that folder didn't exist, so it renamed "New Folder" to "1-36-26 PM, 29 March, 2011", the second time, it sees the "1-36-26 PM, 29 March, 2011" folder and moves "New Folder" into it.

yes but we should only get "1-36-26 PM, 29 March, 2011\New Folder"

Not "1-36-26 PM, 29 March, 2011\New Folder\New Folder"

The overwrite doesnt work and it move the folder inside a "same named" folder instead..

$DirToMove1 = @ScriptDir & "\DirMoveTest\DirToMove1"
$DirToMove2 = @ScriptDir & "\DirMoveTest\DirToOverwrite"
$DirToOverwrite = @ScriptDir & "\DirMoveTest\Result\DirToOverwrite"

$ResultFolder = @ScriptDir & "\DirMoveTest\Result"


DirCreate ($DirToMove1)
FileWriteLine($DirToMove1 & "\File1.txt", "test")
DirCreate ($DirToMove2)
FileWriteLine($DirToMove2 & "\File2.txt", "test")
DirCreate ($DirToOverwrite)


DirMove ($DirToMove1, $ResultFolder,1)
DirMove ($DirToMove2, $ResultFolder,1)

with this example I should get as Result :

File1.txt in @ScriptDir & "\DirMoveTest\Result\DirToMove1

and

File2.txt in @ScriptDir & "\DirMoveTest\Result\DirToOverwrite

Instead I get File2.txt in @ScriptDir & "\DirMoveTest\Result\DirToOverwrite\DirToOverwrite

And with the same example, if we use flag 0 then it move nothing..

Edited by SilentBob999
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...