如何从多个发布目录复制到单个文件夹

发布于 2024-07-26 20:36:33 字数 577 浏览 3 评论 0原文

好吧,我想这与编程无关......

我有一大堆小有用的控制台实用程序分散在我编写的一套项目中,我想将它们全部转储到一个目录中以便使用它们更简单。 唯一的问题是我将它们全部在调试和发布模式下编译。

鉴于我只想要我的实用程序目录中的发布模式版本,什么开关允许我指定我想要树结构中的所有可执行文件,但仅来自发布文件夹内:

示例:

Projects\   
  Project1\
    Bin\
      Debug\
        Project1.exe
      Release\
        Project1.exe   
  Project2\

等等等等...

Utilities\
  Project1.exe
  Project2.exe
  Project3.exe
  Project4.exe
  ...

等等等等...

我认为这对于 XCopy 来说是小菜一碟 - 但它似乎不允许我排除调试目录 - 或者更确切地说 - 只包含我的发布目录中的项目。

有任何想法吗?

Okay this is and isn't programming related I guess...

I've got a whole bunch of little useful console utilities scattered across a suite of projects that I wrote and I want to dump them all to a single directory to make using them simpler. The only issue is that I have them all compiled in both Debug and Release mode.

Given that I only want the release mode versions in my utilities directory, what switch would allow me to specify that I want all executables from my tree structure but only from within Release folders:

Example:

Projects\   
  Project1\
    Bin\
      Debug\
        Project1.exe
      Release\
        Project1.exe   
  Project2\

etc etc...

To

Utilities\
  Project1.exe
  Project2.exe
  Project3.exe
  Project4.exe
  ...

etc etc...

I figured this would be a cinch with XCopy - but it doesn't seem to allow me to exclude the Debug directories - or rather - only include items in my Release directories.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

好倦 2024-08-02 20:36:33

您可以将其限制为仅发布具有以下内容的可执行文件。 然而,我不认为单独使用 xcopy 可以满足展平的其他要求。 要进行限制:

首先创建一个文件,例如 exclude.txt 并将其放入其中:

\Debug\

然后使用以下命令:

xcopy /e /EXCLUDE:exclude.txt *.exe C:\target

但是,您可以使用 xxcopy(免费用于非商业用途)。 请阅读技术公告#16,了解拼合功能的说明。

如果该技术公告中的声明是正确的,那么它证实了仅使用 xcopy 无法完成扁平化。

以下命令将完全使用 xxcopy 执行您想要的操作:

xxcopy /sgfo /X:*\Debug\* .\Projects\*.exe  .\Utilities

不过,我建议您阅读技术公告,因为它提供了更复杂的扁平化选项。 我选择了上面最基本的一种。

You can restrict it to only release executables with the following. However, I do not believe the other requirement of flattening is possible using xcopy alone. To do the restriction:

First create a file such as exclude.txt and put this inside:

\Debug\

Then use the following command:

xcopy /e /EXCLUDE:exclude.txt *.exe C:\target

You can, however, accomplish what you want using xxcopy (free for non-commercial use). Read technical bulletin #16 for an explanation of the flattening features.

If the claim in that technical bulletin is correct, then it confirms that flattening cannot be accomplished with xcopy alone.

The following command will do exactly what you want using xxcopy:

xxcopy /sgfo /X:*\Debug\* .\Projects\*.exe  .\Utilities

I recommend reading the technical bulletin, however, as it gives more sophisticated options for the flattening. I chose one of the most basic above.

筑梦 2024-08-02 20:36:33

抱歉,我还没有尝试过,但您不应该使用:

xcopy release*.exe d:\destination /s

我目前在我的 Mac 上,所以我无法真正检查确定。

Sorry, I haven't tried it yet, but shouldn't you be using:

xcopy release*.exe d:\destination /s

I am currently on my Mac so, I cant really check to be for sure.

娇女薄笑 2024-08-02 20:36:33

这可能无法帮助您现在将它们全部组装在一个地方,但是您是否考虑过向 Visual Studio 中的项目添加构建后事件(我假设您根据目录名称使用它)

xcopy /Y /I /E "$(TargetDir)\$(TargetFileName)" "c:\somedirectory\$(TargetFileName)"

This might not help you with assembling them all in one place now, but going forward have you considered adding a post-build event to the projects in Visual Studio (I'm assuming you are using it based on the directory names)

xcopy /Y /I /E "$(TargetDir)\$(TargetFileName)" "c:\somedirectory\$(TargetFileName)"

酒几许 2024-08-02 20:36:33

好吧,这可能对你不起作用,因为你似乎使用的是 Windows 计算机。
无论如何,这是逻辑。

# From the base directory
mkdir Utilities
find . -type f | grep -w Release > utils.txt
for f in $(<utils.txt); do cp $f Utilities/; done

您可以将 findcp 行合并为一行,为了便于阅读,我将它们分开。

要在 Windows 计算机上执行此操作,您需要 Cygwin 或一些方便的 Unix 实用程序。
也许 Windows shell 中有工具可以做到这一点......

Ok, this is probably not going to work for you since you seem to be on a windows machine.
Here goes anyway, for the logic.

# From the base directory
mkdir Utilities
find . -type f | grep -w Release > utils.txt
for f in $(<utils.txt); do cp $f Utilities/; done

You can combine the find and cp lines into one, I split them for readability.

To do this on a windows machine you'll need Cygwin or some such Unix Utilities handy.
Maybe there are tools in the Windows shell to do this...

凡间太子 2024-08-02 20:36:33

这可能会帮助您入门:

C:\>for %i in (*) do  dir "%~dpi\*.exe"

在 dir 命令中用作 i 的修饰符,~dp 使用 (*) 中找到的所有内容的驱动器和路径。 如果我在一个包含多个包含可执行文件的子文件夹的文件夹中运行上述命令,我会得到每个文件夹中所有可执行文件的目录列表。

您应该能够修改它以在 ~dpi 部分后面添加 '\bin\release\' 并将目录更改为 xcopy。 做一点实验应该会很容易。

要在批处理文件中使用上面的 for 语句,请将两个位置的 '%' 更改为 '%%'。

This may help get you started:

C:\>for %i in (*) do  dir "%~dpi\*.exe"

Used in the dir command as a modifier to i, ~dp uses the drive and path of everything found in (*). If I run the above in a folder that has several subfolders containing executables, I get a dir list of all of the executables in each folder.

You should be able to modify that to add '\bin\release\' following the ~dpi portion and change dir to xcopy. A little experimentation should make it pretty easy.

To use the for statement above in a batch file, change '%' to '%%' in both places.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文