copying all contents of folder to another folder using batch file?

后端 未结 12 1737
时光取名叫无心
时光取名叫无心 2020-12-12 19:49

I have a folder in C:\\Folder1

I want to copy all the contents of Folder1 to another location, D:\\Folder2

How do I do

相关标签:
12条回答
  • 2020-12-12 20:35

    FYI...if you use TortoiseSVN and you want to create a simple batch file to xcopy (or directory mirror) entire repositories into a "safe" location on a periodic basis, then this is the specific code that you might want to use. It copies over the hidden directories/files, maintains read-only attributes, and all subdirectories and best of all, doesn't prompt for input. Just make sure that you assign folder1 (safe repo) and folder2 (usable repo) correctly.

    @echo off
    echo "Setting variables..."
    set folder1="Z:\Path\To\Backup\Repo\Directory"
    set folder2="\\Path\To\Usable\Repo\Directory"
    echo "Removing sandbox version..."
    IF EXIST %folder1% (
        rmdir %folder1% /s /q
    )
    echo "Copying official repository into backup location..."
    xcopy /e /i /v /h /k %folder2% %folder1%
    

    And, that's it folks!

    Add to your scheduled tasks and never look back.

    0 讨论(0)
  • 2020-12-12 20:37
    @echo off
    :: variables
    echo Backing up file
    set /P source=Enter source folder:
    set /P destination=Enter Destination folder:
    set xcopy=xcopy /S/E/V/Q/F/H/I/N
    %xcopy% %source% %destination%
    echo files will be copy press enter to proceed
    pause
    
    0 讨论(0)
  • 2020-12-12 20:38

    On my PC, xcopy and robocopy need also the path to them, i.e. C:\Windows\System32\xcopy.exe

    That's why I use simply "copy": copy /y ....\Folder1\File.txt ....\Folder2\

    0 讨论(0)
  • 2020-12-12 20:44

    xcopy.exe is the solution here. It's built into Windows.

    xcopy /s c:\Folder1 d:\Folder2
    

    You can find more options at http://www.computerhope.com/xcopyhlp.htm

    0 讨论(0)
  • 2020-12-12 20:44
    @echo off
    ::Ask
    echo Your Source Path:
    set INPUT1=
    set /P INPUT1=Type input: %=%
    
    echo Your Destination Path:
    set INPUT2=
    set /P INPUT2=Type input: %=%
    
    xcopy %INPUT1% %INPUT2% /y /s
    
    0 讨论(0)
  • 2020-12-12 20:46

    if you want remove the message that tells if the destination is a file or folder you just add a slash:

    xcopy /s c:\Folder1 d:\Folder2\

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