Package for copying files using xcopy

I have tested some examples on the Internet, but I cannot get my (first) batch file to work. I would like to automatically copy a file from a folder to another, but nothing happens.

@echo off xcopy "C:\source\" "C:\target\" /c /d /i /y exit 

Could you see something wrong?

Thanks!!

Update: I executed the Bali C command, but it still does not work. See Snapshot

 xcopy C:\folder1 C:\folder2\folder1 /t /e /i /y xcopy C:\folder1 C:\folder2\ /t /e /i /y 

Picture:
image

I need to stop it with CTRL + C.

PS: I'm on Win 7

Update (solution): It works! The problem was the name xcopy, bat on my desktop, and I was executing the command from there, so it was executing the xcopy.bat file on my desktop, not Windows. I had to rename the file using "myxcopy". bat ":

 @echo off xcopy "C:\source" "C:\target" /c /d /i /y exit 
+4
source share
4 answers

After testing most of the switches, this worked for me:

 xcopy C:\folder1 C:\folder2\folder1 /t /e /i /y 

This will copy the folder folder1 to the folder folder2 . Thus, the directory tree will look like this:

 C: Folder1 Folder2 Folder1 
+6
source

Based on xcopy help, I tried and found that the following works fine for me (tested on Win 7)

 xcopy C:\folder1 C:\folder2\folder1 /E /C /I /Q /G /H /R /K /Y /Z /J 
+4
source

You must indicate your file in a copy:

 xcopy C:\source\myfile.txt C:\target 

Or if you want to copy all txt files, for example

 xcopy C:\source\*.txt C:\target 
+1
source

If you need to copy all the files in "\ Publish \ Appfolder" to the parent folder "\ Publish" (including any subfolders, the following works for me) The '/ s' switch allows you to recursively copy all subfolders.

xcopy src\main\Publish\Appfolder\*.* /s src\main\Publish\

+1
source

Source: https://habr.com/ru/post/1394413/


All Articles