当前位置: 动力学知识库 > 问答 > 编程问答 >

windows - Can xcopy transfer the files in a subdirectory, but not the directories themselves?

问题描述:

Essentially, what I want to do is copy *.txt from the current directory as well as all the subdirectories. If I do xcopy /s /e C:\source C:\dest, it copies not just the files, but the directory structure as well. I need only the files to be copied, so C:\dest contains nothing but *.txt files. I checked the documentation for both xcopy and robocopy, but I couldn't find any parameters that allowed this functionality.

网友答案:

How about using a FOR loop? It'll execute lots of copy commands, but give it a try:

FOR /R C:\source %%f IN (*.txt) DO xcopy /s "%%f" "C:\dest"
分享给朋友:
您可能感兴趣的文章:
随机阅读: