DOS命令 - 剔除XCOPY文件夹中文件 [英] DOS Commands- Excluding files in a folder in xcopy

查看:265
本文介绍了DOS命令 - 剔除XCOPY文件夹中文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含很多其他子文件夹的文件夹。
我试图写一个批处理文件,该文件将一些文件夹复制到另一个地方,在我的硬盘上。我使用XCOPY这一点。我面临的问题如下:
文件夹结构是如图如下─

--FolderB1

--- FolderB2

--- FolderB22

--- FILE1.TXT

--- FILE2.TXT

--- File3.txt


I have a folder containing many other sub-folders. I am trying to write a batch file which will copy some of the folders to another place on my hard disk. I am using "xcopy" for this. I am facing following problem: The folder structure is as shown below-
--FolderB1
---FolderB2
---FolderB22
---File1.txt
---File2.txt
---File3.txt


  • 我里面的FolderB1一些.txt文件,以FolderB2,并沿
    FolderB22我想复制FolderB2和FolderB22,然后跳到名.txt
    载文件夹B1

  • I have some .txt files inside "FolderB1", along with "FolderB2" and "FolderB22" I want to copy "FolderB2" and "FolderB22" and skip ".txt" files contained in "Folder B1"

我试着使用/排除:xcopy命令的参数,但它不能执行此操作。如果我指定排除因为它不工作的 \\ FolderB1 \\ *。txt的或这类的东西。

I tried using /EXCLUDE: param of xcopy command, but it is not able to perform this operation. It does not work if I specify the exclusion as \FolderB1\*.txt or something of this sort.

主文件夹的数量是未知的。它可以是任何东西。此外,还有为名为.txt文件名没有固定的模式。已检查<一href=\"http://stackoverflow.com/questions/2300863/how-do-i-copy-files-from-1-folder-to-another-while-excluding-certain-file-types\">this问题太多,但没有帮助。

The number of main folders is not known. It can be anything. Also, there is no fix pattern for names of ".txt" files. Have checked this question too, but did not help.

另一种方法或其他指针一样将是一个很大的帮助。先谢谢了。

Alternate method or other pointers for the same would be a great help. Thanks in advance.

推荐答案

有什么你可以尝试做的是隐藏文件,你不想复制,然后执行XCOPY,然后再取消隐藏文件。

What you could try to do is to hide the files you don't want to copy, then execute the xcopy, and then unhide the files again.

看看我的问题,<一个答案href=\"http://stackoverflow.com/questions/3008567/windows-batch-script-to-delete-everything-in-a-folder-except-one\">Windows批处理脚本删除文件夹的一切除了一个。那问题是相关的做删除文件(包括某些文件),但你也许可以用同样的伎俩XCOPY-ING文件。

Look at my answer of question Windows batch script to delete everything in a folder except one. That question was related do deleting files (excluding some files), but you can probably use the same trick for xcopy-ing files.

这篇关于DOS命令 - 剔除XCOPY文件夹中文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆