Post build script to copy all the files from different to output directory

3.7k views Asked by At

I want to copy multiple files from different folders which are inside my project directory to my output directory using post build command. Is there a way by using a post build command to copy all the files from these different folders to my bin\debug folder. I used xcopy with the switches /s. But it did not work

Folder1
 File1
 File2
Folder2
 File3
 File4
FOlder3
 File5
 File6

Output
..\bin\debg
   File1
   File2
   File3
   File4
   File5
   File6
1

There are 1 answers

4
starian chen-MSFT On BEST ANSWER

Refer to this command to achieve your requirement:

xcopy /Y /I /E "$(ProjectDir)ParentFolder\*.*" "$(TargetDir)ParentFolder" 

Update:

Copy files to a single folder (simple code):

if not exist "$(TargetDir)LibTest" mkdir $(TargetDir)LibTest 
pushd $(ProjectDir)LibTest
   for /r %%a in (*.*) do (
     copy "%%a" "$(TargetDir)LibTest"
   )
   popd