Copy files recursively from a hierarchy to a single flat folder

随声附和 提交于 2019-12-13 05:24:16

问题


Is it possible to copy all the files contained recursively from a specific folder and its subfolders directly to a only one flat directory without respecting anymore the source hierarchy folders?


回答1:


Of course that's possible. Why not?

Counter = 0
Get-ChildItem -Path <Path> -Filter * -Recurse -File |
    Copy-Item -Destination <Destination Path> -PassThru |
        Foreach-Object{
            $counter++
            Rename-Item -Path $_.FullName -NewName ($_.BaseName + '_' + ("{0:000}" -f $Counter) + $_.Extension)
        }


来源:https://stackoverflow.com/questions/49852380/copy-files-recursively-from-a-hierarchy-to-a-single-flat-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!