how can I copy one file to multiple sub directories
I'm trying to use nant because I thought it would be the easiest, but i'm open to any solution that works on windows xp.
I have the following folder structure
basefolder
folder1
folder2
subfolder1
code
solutionname1
projectname.interface
projectname.simulation
projectname.testcase
bin
release
folder3
...
folderN
folder1 - folderN all have the same directory structure as folder2. I want to copy a file to the release folder in each folderN.
I currently have the following nant script
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://nant.sf.net/release/0.90/nant.xsd" name="CopyDll" default="FileCopy">
<property name="fileToCopy"
value="C:\file.dll"
overwrite="false"/>
&开发者_开发技巧lt;property name="baseDirectory" value="${directory::get-current-directory()}" overwrite="false"/>
<target name="FileCopy"
description="Copies file to multiple directories">
<foreach item="Folder"
in="${baseDirectory}"
property="foldername">
<in>
<items>
<include name="**\**\**\*.TestCase\bin\Release"/>
</items>
</in>
<do>
<copy file="${fileToCopy}"
todir="${foldername}"/>
<echo message="Copied file to ${foldername}"/>
</do>
</foreach>
</target>
</project>
This copies file.dll to each folderN directory. What am I doing wrong? Is there a better way to do this?
I figured it out. I had to change my foreach to look like this
<foreach item="Folder"
property="foldername">
<in>
<items>
<include name="${baseDirectory}\**\*.TestCase\bin\Release"/>
</items>
</in>
<do>
<copy file="${fileToCopy}"
todir="${foldername}"/>
<echo message="Copied file to ${foldername}"/>
</do>
</foreach>
精彩评论