Sign in to follow this  
Followers 0
redfive19

DirCopy not working as intended

7 posts in this topic

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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Well I have the newest Autoit (3.1.1) installed and the newest beta. I tried it using a BetaRun and a regular run. I'll try it with the code you posted.

Share this post


Link to post
Share on other sites

well, you were right....it came up with an error. now to find out why!

Share this post


Link to post
Share on other sites

so far, no problems copying via explorer, waiting for one to crop up actually. maybe autoit approaches the directory copies differently then explorer and explorer will hit the bump at a different time!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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]

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