Jump to content

Need little help with copy folder to folder


Borje
 Share

Recommended Posts

Hello all users

I need little help with this command what I want is this not should owerwrite files in $indest folder what can I do?

$runcmd = @ComSpec & " /c copy /y " & chr(34) & $insource & chr(34) & " " & Chr(34) & $indest & Chr(34)

My $insource dir is : d:backup1 and my $indest is: d:backup2

This works but that not need to owerwrite the files in dest folder on every run.

Perhaps somebody have a tips..

Regards

Borje

Link to comment
Share on other sites

  • Developers

Hello Danyfirex

 

I am not sure how to convert this to filecopy do you have som example?

did you really open the helpfile and have issues coding this after reading it ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Yes i have do that but cant have this to work the filecopy not works to but if that are somebody that help me with this

$runcmd = @ComSpec & " /c copy /y " & chr(34) & $insource & chr(34) & " " & Chr(34) & $indest & Chr(34)

To have that to not owerwrite the destination files..

Link to comment
Share on other sites

  • Developers

Open the helpfile, check for filecopy and read.

Code the command and test.

Come back when you have issues and show us the code you have.

Simple enough ..right ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

mmmm looks like you have already done quite some coding.

So what is the issue exactly?  Do you only want to replace files in the target directory when the source is changed?

When that is the case you could use xcopy and use the /D parameter.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hello Jos and others

What I want is when I do a backup from the target folder to the destinaton folder  the files in destinaton folder not be owerwitten i think that must be some trick with the @comsec or something.. As function now all files be owerwritten but I not need that...

Link to comment
Share on other sites

Didn't you see my last post ? here is the trick

This :

$runcmd = @ComSpec & " /c echo n|copy /-y " & chr(34) & $insource & chr(34) & " " & Chr(34) & $indest & Chr(34)

will cause a prompt to overwrite ( /-y ) with an automatic 'no' answer ( echo|n )    :)

Link to comment
Share on other sites

Jos gave you your answer, use Xcopy instead of Copy in your command string, and use the /D parameter.

Check xcopy out at the DOS prompt, if you need to.

P.S. Or you could code some file checking (exists, size and date comparisons), and thus use the AutoIt function - FileCopy.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Hello mikell

Thanks for your helping me with this I also try xcopy but Cant have this to work perhaps that are something in the code I have not write all in this code.

have problem with progress bar.

I have also test with a textfile with same name an change the content in the source but it update the destination also owerwrite have you tested the code I uploaded ?

Link to comment
Share on other sites

@Borje, you can try this:

$fileSrc = FileSelectFolder("Select the Source folder", "C:\")
$fileDst = FileSelectFolder("Select the Destination folder", "C:\")

If FileCopy($fileSrc, $fileDst) Then
    MsgBox(0, "Success", "Files Copied with SUCCESS!" & @CRLF & "No files overwrited")
Else
    MsgBox(0, "Failure", "Something wrong happened!")
EndIf

Tell me if works to you, for me it's working :)

And if you need to copy Directory and sub-directories, use DirCopy instead FileCopy

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