复制文件而不重新创建子目录 [英] Copy files without recreating subdirectories
问题描述
我有一个包含约100个子文件夹的目录,这些子文件夹中有近2,000个文件(最多4层)。文件是.txt或.log,每个扩展名都有唯一的文件名。我需要将文件移动或复制(以较快的速度为准)到另一个文件夹的根目录,而不必像xcopy那样重新创建子文件夹结构。这是在Windows xp上
I have a directory that has about 100 subfolders and close to 2,000 files within those subfolders (up to 4 layers). The files are .txt or .log, and each extension has a unique file name. I need to move or copy (whichever is faster) the files to the root of a different folder without recreating the subfolder structure like xcopy does. This is on Windows xp
谢谢。
现有:
Dir1\Folder1\000111.txt
Dir1\Folder2\000112.txt
Dir1\Folder3\000113.log
Dir1\Folder4\Dir2\000114.txt
Dir1\Folder4\Dir2\000115.txt
Dir1\Folder4\Dir2\000116.log
Dir1\Folder5\Dir3\000117.log
Dir1\Folder5\Dir3\000118.txt
Dir1\Folder5\Dir3\Dir4\000119.txt
Dir1\Folder5\Dir3\Dir4\000120.txt
Dir1\Folder5\Dir3\Dir4\000120.log
必需:
Dir9\000111.txt
Dir9\000112.txt
Dir9\000113.log
Dir9\000114.txt
Dir9\000115.txt
Dir9\000116.log
Dir9\000117.log
Dir9\000118.txt
Dir9\000119.txt
Dir9\000120.txt
Dir9\000120.log
推荐答案
怎么样:
for /R %f in (*.txt,*.log) do copy %f dir9\%~nf
以 dir1
发出该问题您的工作目录。
Issue this with dir1
as your working directory.
对/?有的读物?
以了解其工作原理。
Have a read of for /?
to understand why this works.
当我在中处理
语句时,我倾向于像这样首先尝试它们:
When I work on for
statements I tend to try them out first like so:
for /R %f in (*.txt,*.log) do @echo copy %f dir9\%~nf
这篇关于复制文件而不重新创建子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!