如何将一个文件复制到多个子目录
我尝试使用 nant 因为我认为它是最简单的,但我对任何适用于 Windows XP 的解决方案持开放态度。
我有以下文件夹结构
basefolder
folder1
folder2
subfolder1
code
solutionname1
projectname.interface
projectname.simulation
projectname.testcase
bin
release
folder3
...
folderN
folder1-folderN都具有与folder2相同的目录结构。我想将一个文件复制到每个文件夹N中的release文件夹中。
我目前有以下 nant 脚本,
<?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"/>
<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>
它将 file.dll 复制到每个folderN目录。 我做错了什么? 有更好的方法吗?
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"/>
<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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了。我不得不改变我的 foreach 看起来像这样
I figured it out. I had to change my foreach to look like this