XCOPY 排除列表在第一次排除后被忽略

发布于 2024-07-22 22:21:37 字数 511 浏览 11 评论 0原文

我创建了一个批处理文件,它使用 xcopy 复制目录和子目录,并将它们合并到一个文件中。 (即我所有的模块化开发 CSS 样式表都合并到一个生产样式表中)。

一切都很好,除了当我引用 exceptlist.txt 时,它只排除第一行,而不排除我想要排除的后续文件。

有人想破解这个吗? 你会很有帮助的。

这是代码:

XCOPY C:\xampp\htdocs\PROJECT\css\*.* C:\temp /S /I /Y /EXCLUDE:C:\xampp\htdocs\PROJECT\exclude.txt

...在我的 except.txt 中是...

1.css
2.CSS
3.CSS
4.CSS
5.css

///// 我知道代码可以工作(在某种程度上),因为它实际上排除了文件 1.css —— 只是不包括它下面的文件。 我将每个排除项放在新行中是否正确?

I have a batch file I've created which uses xcopy to copy a dir, and child dirs, and merge them into one file. (ie. all my modulised development css stylesheets merged into one production stylesheet).

Everything is good, apart from the fact that when I reference the excludelist.txt, it only excludes the first line, and not the subsequent files I want excluded.

Anyone fancy a crack at this? You'd be most helpful.

Here's the code:

XCOPY C:\xampp\htdocs\PROJECT\css\*.* C:\temp /S /I /Y /EXCLUDE:C:\xampp\htdocs\PROJECT\exclude.txt

...and inside my exclude.txt is...

1.css
2.css
3.css
4.css
5.css

///// I know the code works (to an extent) because it is infact excluding file 1.css -- just not the ones below it. Am I right to put each exclusion on a new line?

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

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

发布评论

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

评论(5

谁许谁一生繁华 2024-07-29 22:21:37

您似乎正确使用了 xcopy - 每个排除文件(或取决于通配符的匹配)应该位于文件内的新行上。 到目前为止,我无法重现您所经历的行为。

您在上面给出的 except.txt 列表是测试文件,还是实际的 CSS 名称?
您的批处理文件要复制的其他文件的名称是什么?

编辑:
xcopy 在一次匹配后无法排除更多文件,这一点让我犹豫不决。 我认为这可能与排除文件中使用的回车符类型有关,但 xcopy 可以很好地处理 unix 风格的回车符。

您能否重新验证是否使用了正确的排除文件?

You seem to be using xcopy correctly - each exclusion file (or match depending on wildcards) should be on a new line within the file. So far I've been unable to reproduce the behaviour you're experiencing.

Is the exclude.txt listing you've given above a test file, or are they the actual css names?
What are the names of the other files that your batch file is supposed to copy?

Edit:
That the xcopy is failing to exclude further files after a single match is giving me most pause. I thought it might be to do with the type of carriage-return that was used in the exclude file, but xcopy handles unix-style carriage-returns just fine.

Can you re-verify that the correct exclude file is being used?

路弥 2024-07-29 22:21:37

我使用以下内容,

xcopy "C:\users\dad\*.*" dad /s /d <yesnoyesno /EXCLUDE:excluexclu 1>cop.txt 2>err.txt

因为我在网络上的某个地方看到了一条注释,大意是 /Y 开关不能直接与排除文件一起使用。

我想在这里指出的是有用的输出文件 1 和 2。 2、其中详细介绍了成功与否 失败问题。

我的仅显示成功。

I use the following,

xcopy "C:\users\dad\*.*" dad /s /d <yesnoyesno /EXCLUDE:excluexclu 1>cop.txt 2>err.txt

as somewhere on the web I saw a note to the effect that the /Y switch could not be used directly with an exclude file.

What I wanted to point out here, was the useful output files 1 & 2, which detail the success & failure issues.

Mine shows only success.

诗笺 2024-07-29 22:21:37

简短的回答:创建一个新的文本文件,键入条目并保存文件。

更长的解释:我今天在 Windows 2008 服务器上遇到了这个问题。 我尝试了各种方法让它发挥作用。 强制记事本将文件保存为 ANSI、Unicode 和 UTF-8,但它们都有相同的问题。 最后我开始考虑这样一个事实:我通过 FTP 将文件放在服务器上,很可能 FTP 调整了文件格式。 我在服务器上创建了一个新的文本文件,在新文件中键入了所有相同的条目,现在它可以工作了。

The short answer: Create a new text file, type the entries and save the file.

The longer explanation: I ran into this very issue on a Windows 2008 server today. I tried all kinds of things to get it to work. Forced notepad to save the file as ANSI, Unicode and UTF-8 but all of them had the same problem. Finally I started thinking about the fact that I put the file on the server via FTP and it's quite likely that FTP tweaked the file format. I created a new text file on the server, typed all the same entries in the new file and now it works.

落墨 2024-07-29 22:21:37

我有类似的问题。 我试图排除根文件夹和任何子文件夹中具有特定扩展名的所有文件,但它不起作用。 原因是我放置了 *.pdb 而不是 .pdb。 换行符/回车符对我来说完全是转移注意力的事情。

所以我的文件看起来像:

.pdb
.obj
.vb
。CS

I had a similar problem. I was trying to exclude all files with a certain extension in the root folder and any sub-folders and it didn't work. The reason was I was putting *.pdb instead of just .pdb. The newline/carriage return thing was a total red herring for me.

So my file just looked like:

.pdb
.obj
.vb
.cs

一紙繁鸢 2024-07-29 22:21:37

尝试在文本编辑器上强制它以 ANSI 编码保存。
我遇到了类似的问题,那就做到了。

Try forcing it to save with ANSI encoding on your text editor.
I was having a similar issue and that did it.

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