之前我的dot-net项目部署到我的远程服务器,我在一个nant构建配置文件中使用了copy命令.该命令如下所示.
<target name="Deploy">
<copy todir="${path.to.the.directory}" overwrite="true">
<fileset basedir="${Bin.Path}">
<include name="*.*" />
</fileset>
</copy>
</target>
Run Code Online (Sandbox Code Playgroud)
现在,当我的项目增长时,我的$ [bin.path]文件夹中有两个新文件夹,现在我无法使用复制命令将我的可执行文件复制到输出文件夹.
有人可以建议我做什么.
搜索后我发现我可以使用XCopy.但我没有得到如何将其集成到我的构建脚本中,类似于上面显示的那样.
谢谢你的帮助.
有这个目录结构:
Dir1
--Dir2
--File1
--File2
--Dir3
--File3
--File4
--File5
Run Code Online (Sandbox Code Playgroud)
现在我想使用批处理文件将子目录(Dir2,Dir3)中的所有文件复制到父目录Dir1.我已经提出了下面的代码,但它并不完美.我得到以下输出 -
Directory2 --It has 4 files all together
Invalid number of parameters
Invalid number of parameters
Does E:\Directory1\Copy\File1.dat specify a file name -- And only this file gets copied
or directory name on the target
(F = file, D = directory)?
Run Code Online (Sandbox Code Playgroud)
代码 -
@echo off
call :treeProcess
Pause
goto :eof
:treeProcess
rem Do whatever you want here over the files of this subdir, for example:
for /D %%d in (*) …Run Code Online (Sandbox Code Playgroud) 我必须复制一个文件(在安装时)驻留在同一个文件夹中exe,msi installer并存在于某个不同的路径中.为此,我在installer课堂上写了下面的代码.
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "xcopy";
startInfo.UseShellExecute = true;
string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string SourcePath = Path.GetFullPath("C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin");
StreamWriter sw = new StreamWriter(@"C:\Users\lovestone\Desktop\data.txt");
sw.WriteLine(directory);
sw.WriteLine(SourcePath);
startInfo.Arguments = "\"" + directory + "\"" + " " + "\"" + SourcePath + "\"" + @" /e /y /I";
process.StartInfo = startInfo;
process.Start();
Run Code Online (Sandbox Code Playgroud)
我对该installer类没有任何问题,因为它data.txt在给定路径上创建(在安装时).我应该怎么做,从复制文件directory到SourcePath?
我应该用 …
我有两个文件夹,我使用命令从源文件夹备份到目标文件夹:
xcopy /E /Y /I /D
Run Code Online (Sandbox Code Playgroud)
现在我想删除目标文件夹中源文件夹中不存在的文件.
我需要使用bat文件将源文件复制到目标文件夹。
我创建了这个:
@echo off
set source="D:\Folder1\file.dll"
set destination="D:\Test\TestCopy*\Test\"
xcopy /s /y %source% %destination%
pause
Run Code Online (Sandbox Code Playgroud)
我的目标路径是TestCopy.2.5.3.6。这个数字可以改变。所以指定TestCopy*不起作用。指定TestCopy.*.*.*.*也不起作用。
我该如何解决?
我之前曾寻找过我的问题的答案,但到目前为止还没有具体的答案。请参阅:使用 xcopy 将文件从多个目录复制到一个目录和批处理文件将文件从一个文件夹复制到另一个文件夹。
在一个目录 ( Data) 中,我专门命名了多个目录,例如 ( SIAE02203),其中包含通用命名的 .JPEG 文件 ( plot.jpeg)。我希望创建一个批处理文件,能够遍历每个目录,找到,复制并plot.jpeg使用父文件夹名称重命名该文件。
于是就plot.jpeg变成了SIAE02203-plot.jpeg。
目录的结构如下所示:Data\SIAE02203\plots\plot.jpeg。我希望将重命名的文件复制到Data\Output.
这有可能吗?
我有几个扩展,我想从xcopy中排除.我不知道那些文件夹/目录可能存在.
以下是我正在使用的命令:
xcopy /r /d /i /s /y C:\test1 C:\test2 /exclude:.txt+.exe
Run Code Online (Sandbox Code Playgroud)
Anh对此有所帮助?