Question

I am using Visual Studio 2012.

I have the following xcopy command

set myDir="$(SolutionDir)\MyFolder\MySubfolder"
xcopy /D /Y /I /G /R /E %myDir% "$(TargetDir)"

This only copies the contents of MySubfolder to the TargetDir. But I want it to create the whole folder.

  • Right now if I have:

    MySubfolder\file1

    MySubfolder\file2

  • And with my command I get:

    $(TargetDir)\file1

    $(TargetDir)\file2

  • I want:

    $(TargetDir)\MySubfolder\file1

    $(TargetDir)\MySubfolder\file2

I've tried several xcopy parameters but none seems to work.

Is there a way to accomplish this with xcopy?

Was it helpful?

Solution

You have to do as follows:

set myDir="$(SolutionDir)\MyFolder\MySubfolder"
xcopy /D /Y /I /G /R /E %myDir% "$(TargetDir)\MySubfolder"

Include the folder you want in the target directory also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top