Sign in to follow this  
Followers 0
Borje

Need little help with copy folder to folder

18 posts in this topic

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

Share this post


Link to post
Share on other sites



why not filecopy? Saludos

Share this post


Link to post
Share on other sites

Hello Danyfirex

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

Share this post


Link to post
Share on other sites

FileCopy("d:\backup1\*.*", "d:\backup2\")

RTFM

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


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

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

?

echo n|copy /-y <source> <dest>

Share this post


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

Share this post


Link to post
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 )    :)

Share this post


Link to post
Share on other sites

Hi mikell

Thanks for your trick I have test little but I think it still owerrite files I se that on time have you tested this?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


Link to post
Share on other sites

 I have test little but I think it still owerrite files I se that on time have you tested this?

 

I tested using txt files with same names but different contents and it works on my XP - the content of files in dest folder doesn't change

Share this post


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

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

@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

Share this post


Link to post
Share on other sites

Hello Darkwarlor

Your example works but I still have problem in my main script and I cant find any solution.

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