将文件从层次结构递归复制到单个平面文件夹 [英] Copy files recursively from a hierarchy to a single flat folder

查看:65
本文介绍了将文件从层次结构递归复制到单个平面文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将特定文件夹及其子文件夹中的所有递归文件直接复制到一个平面目录,而无需再遵守源层次结构文件夹?

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?

推荐答案

当然可以。为什么?

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)
        }

这篇关于将文件从层次结构递归复制到单个平面文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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