Jump to content

DirCopy not working as intended


Recommended Posts

Hello all,

Trying to do a simple directory copy and DirCopy is NOT copying the folder structure underneath the folder I am copying.

DirCopy("D:\Documents and Settings\jermaid\My Documents", "C:\testcopy", 1)

When I run this, it only copies the files from the root of My Documents but not the folders in the My Documents folder. I have a strange feeling that I am missing something real simple here. Would someone slap me into reality and tell me what I am doing wrong?

Regards,

Redfive

Link to comment
Share on other sites

What version of AutoIt and Windows?

-You might want to check the return value.

-You might try doing a copy and paste in explorer. If explorer thinks some file is "in use"--usually due to some invalid locking handle--then the copy might abort.

$source = "D:\Documents and Settings\jermaid\My Documents"
$destination = "C:\testcopy"

$result = DirCopy($source, $destination, 1);1==overwrite

MsgBox(4096,"Result", $result)

DirCopy worked for me as expected on 3.1.1.0 on WinXP Pro sp2

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Okay since both AutoIt & XCOPY encountered problems (while explorer did not) this is the command that finally worked for me

Runwait(@ComSpec & " /c " & "xcopy " & '"' & $source & '"' & ' "' & $destination & '"' & " /E /C")

I know I can also hide the window but i'd rather leave it up to show that it's working (that whole progress bar still boggles my mind!!!)

Now on a complete side note, how do you change the color of the DOS window that pops up? I know the COLOR command does it but how do you pass it on to the window before you run XCOPY?

thanks for your help!

-redfive

Edited by redfive19
Link to comment
Share on other sites

I know the COLOR command does it but how do you pass it on to the window before you run XCOPY?

CMD.EXE recognizes the ampersand character to run commands sequentially.

You can also use && to only run the following command if the first succeeds, || to run only if the first fails.

Try this:

Run(@ComSpec & ' /c color 2e & xcopy "'' & $source & ' "' & $destination & '" /E /C')

btw, I haven't had any issues at all with DirCopy().

Edit: You can also pass the /T:xx parameter to CMD.exe instead of using COLOR.

This parameter and the Ampersand syntax will not work in 9x, which use command.com.

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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...