繁体   English   中英

如何将例如 200 个文件夹分类为 8 个父文件夹,每个文件夹有 25 个子文件夹? (视窗 10)

[英]How to sort e.g. 200 folders into 8 parent folders of 25 subfolders each? (Windows 10)

我有 200 个单独的文件夹,每个文件夹中有 50 个文件。 我想将这 200 个单独的文件夹分类为 8 个父文件夹,每个文件夹有 25 个子文件夹,同时保留子文件夹中的所有文件。

理想情况下,父文件夹的命名结构应遵循基于短语的顺序模式(例如“rvolkov Files 1”、“rvolkov Files 2”等)。

我试图找到上面的 powershell 脚本,但它似乎只适用于文件而不是文件夹,所以我无法使用它( here

如何在 Windows 10 中执行此操作? 如果有帮助,各个文件夹以条形码命名,因此前几位数字相同。

先感谢您

根据我认为是您的问题,这是一个可能的解决方案:

# GeneralParameters
$dir         = "C:\yourdirhere"
$ParentDepth = 8
$FolderCount = 25

$dirs        = gci $dir -Directory
cd $dir         #Makes it easier to debug and read the code, not entirely necessary.
$SubCounter = 0

for ($ParentCounter=1;$ParentCounter -le $ParentDepth;$ParentCounter ++) {
    mkdir "Parent$ParentCounter"
    for ($i=1;$i -le $FolderCount; $i++) {
        Move-Item -Path $dirs[$SubCounter].FullName -Destination "Parent$ParentCounter"
        $SubCounter++
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM