如何从文件夹树中删除所有文件夹使用Robocopy复制文件? [英] How to copy files from folder tree dropping all the folders with Robocopy?

查看:653
本文介绍了如何从文件夹树中删除所有文件夹使用Robocopy复制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下文件夹结构:



FolderA

--Folder1

--Folder2

--Folder3

...

--Folder99



文件夹1到99中有文件。



我所要做的就是将所有文件复制到一个文件夹中,基本上做一个FolderA副本,并擦除保存所有文件的文件夹1-99。 p>

如果可能的话,我想从cmd.exe中使用Robocopy。(Windows Server 2008)

解决方案

为什么使用 robocopy



您可以直接使用 cmd 给你:

  for / r%f in(*)do @copy%ftarget 

这将基本上展平您的目录层次结构。 for / r 将循环遍历目录树,查找与给定模式匹配的文件名。您还可以指定开始的目录:

  for / r FolderA%f in(*)do @copy%f target 

在循环中它只是将文件复制到指定文件夹中。


I have the following folder structure:

FolderA
--Folder1
--Folder2
--Folder3
...
--Folder99

Folders 1 through 99 have files in them.

All I want to do is to copy ALL THE FILES into ONE FOLDER, basically do a FolderA copy, and wipe out Folders 1-99 keeping all the files.

I'd like to do it with Robocopy from cmd.exe if possible (Windows Server 2008)

解决方案

Why use robocopy? It's a good tool for a specific task but this is not the one.

You can simply use what cmd already gives you:

for /r %f in (*) do @copy "%f" target

This will essentially "flatten" your directory hierarchy. for /r will walk a directory tree recursively, looking for file names matching the given pattern. You can also specify the directory to start in:

for /r FolderA %f in (*) do @copy "%f" target

Within the loop it's just a simply copy of the file into a specified folder.

这篇关于如何从文件夹树中删除所有文件夹使用Robocopy复制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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