none
copy files to another directory (if exist, skip copy files, don't overwrite) RRS feed

  • Question

  • Hi Guys,

    i have windows server 2012 on my servers.

    i want to copy files from folder A to folder B using batch. but, i usually using 'copy', but this 'copy' will overwrite the files that exist in B folder.

    so the question is, anybody know the script batch to copy files from A to B but it won't overwrite the files if exist, it means just copy files from folder A if not exist in folder B?

    for example, in D:\Folder\ there are test1.txt, test2.txt, test3.txt. and in \\10.163.100.100\Folder\ there are test1.txt.

    i want to make a batch that will copy test2, and test3 from D to 10.163.100.100, because test1 is already in there.

    because when i try to use xcopy it doesn't work anyway.

    Thank you


    yoga

    Tuesday, June 14, 2016 2:24 AM

Answers

All replies

    • Marked as answer by king.yhk Tuesday, June 14, 2016 4:33 AM
    Tuesday, June 14, 2016 2:34 AM
  • Hi JRv

    Thanks for the answer, now i can copy it and tested successfully, thanks alot..


    yoga

    Tuesday, June 14, 2016 4:33 AM
  • You are welcome.  RoboCopy is an excellent tool.

    \_(ツ)_/

    Tuesday, June 14, 2016 1:09 PM
  • but how to copy the folder? i forgot that i have a folder and a txt file.

    for example in dir D:\ there are folder named by Bkp_Log1, Bkp_Log2, and Bkp_Log3. and there are txt file with that name too.

    i have used robocopy /XO /XN Bkp_Log* , but the file that copied is only the txt file. the 3 folder isn't copied yet. am i miss something?

    i have tried with /s no folder copied, /copyall neither


    yoga


    • Edited by king.yhk Wednesday, June 15, 2016 2:16 AM
    Wednesday, June 15, 2016 1:42 AM
  • This is not a robocopy Q&A forum. I would recommend reading the documentation for robocopy. (You can search for it. Just type "robocopy documentation" in a search engine.)


    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 15, 2016 2:15 AM
    Moderator
  • i know its not. but this is about script right? and im in scripting guys forum.

    am i wrong to ask? sorry about that.

    because i have search in google for this, and i found nothing.

    i just want to copy my backup file in my PC into fileserver, and that's always failed.


    yoga

    Wednesday, June 15, 2016 2:52 AM
  • but how to copy the folder? i forgot that i have a folder and a txt file.

    for example in dir D:\ there are folder named by Bkp_Log1, Bkp_Log2, and Bkp_Log3. and there are txt file with that name too.

    i have used robocopy /XO /XN Bkp_Log* , but the file that copied is only the txt file. the 3 folder isn't copied yet. am i miss something?

    i have tried with /s no folder copied, /copyall neither


    yoga


    Read the RoboCopy help and learn how to use it.

    For RoboCopy support use the forum for yur version of Windows.  It is a system utility command and not a script.


    \_(ツ)_/

    Wednesday, June 15, 2016 3:12 AM
  • okay i have found the solution for this problem..

    im sorry if i did a mistake. Thanks for your support guys,

    you help me so much..

    Thank you


    yoga

    Wednesday, June 15, 2016 6:07 AM