[batch-file] batch to copy files with xcopy

I have checked some examples on internet but I can't get my (first) batch file to work. I would like to copy automatically my file from a folder to another one but nothing happen.

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

Could you see anything wrong?

Thanks!!

Update: I have done the command given by Bali C but it still doesn't work. See snapshot

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

Image:
image

I have 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 running the command from there, so it was executing the xcopy.bat file of my desktop instead of the Windows one.. I had to rename the file with "myxcopy.bat" :

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

This question is related to batch-file xcopy

The answer is


If the requirement is to copy all files in "\Publish\Appfolder" into the parent "\Publish\" folder (inclusive of any subfolders, following works for me) The switch '/s' allows copying of all subfolders, recursively.

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


You must specify your file in the 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

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

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