Batch file to copy files from one folder to another folder

前端 未结 9 1591
臣服心动
臣服心动 2020-11-29 15:07

I have a storage folder on a network in which all users will store their active data on a server. Now that server is going to be replaced by a new one due to place problem s

相关标签:
9条回答
  • 2020-11-29 15:31

    To bypass the 'specify a file name or directory name on the target (F = file, D = directory)?' prompt with xcopy, you can do the following...

    echo f | xcopy /f /y srcfile destfile

    or for those of us just copying large substructures/folders:

    use /i which specifies destination must be a directory if copying more than one file

    0 讨论(0)
  • 2020-11-29 15:33

    Just to be clear, when you use xcopy /s c:\source d:\target, put "" around the c:\source and d:\target,otherwise you get error.

    ie if there are spaces in the path ie if you have:

    "C:\Some Folder\*.txt"
    

    but not required if you have:

    C:\SomeFolder\*.txt
    
    0 讨论(0)
  • 2020-11-29 15:39
    @echo off
    
    rem The * at the end of the destination file is to avoid File/Directory Internal Question.
    
    rem You can do this for each especific file. (Make sure you already have permissions to the path)
    xcopy /Y "\\Oldeserver\storage\data\MyFile01.txt" "\\New server\storage\data\MyFile01.txt"*
    pause
    
    rem You can use "copy" instead of "xcopy "for this example.
    
    0 讨论(0)
  • 2020-11-29 15:41

    My favorite one to backup data is:

    ROBOCOPY "C:\folder" "C:\new_folder" /mir
    

    /mir is for mirror. You can also use /mov to move files. It reproduce the exact same folder. It can delete/overwrite files as needed. Works great for me. It's way faster than xcopy / copy. It's built in Windows as well.

    Source: http://technet.microsoft.com/en-us/library/cc733145.aspx

    0 讨论(0)
  • 2020-11-29 15:43

    You can use esentutl to copy (mainly big) files with a progress bar:

    esentutl /y "my.file" /d "another.file" /o
    

    the progress bar looks like this:

    0 讨论(0)
  • 2020-11-29 15:50

    Look at rsync based Windows tool NASBackup. It will be a bonus if you are acquainted with rsync commands.

    0 讨论(0)
提交回复
热议问题