How to copy files from folder tree dropping all the folders with Robocopy?

后端 未结 3 1303
-上瘾入骨i
-上瘾入骨i 2020-12-08 19:28

I have the following folder structure:

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

Folders 1 through 99 have files in them.

相关标签:
3条回答
  • 2020-12-08 19:55

    Robocopy is a great tool... when you have a job it can handle. Why not use xcopy?

    If you have two drives you can just use xcopy:

    XCOPY  C:\*.*  D:\NewFolder\   /S
    

    Or use XXCOPY for one drive:

    XXCOPY C:\*.*  C:\NewFolder\   /S /CCY
    

    XXCOPY

    0 讨论(0)
  • 2020-12-08 20:02
    Get-ChildItem -Path source -Recurse -File | Move-Item -Destination dest
    
    0 讨论(0)
  • 2020-12-08 20:07

    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.

    0 讨论(0)
提交回复
热议问题