简体   繁体   English

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

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

I have 200 individual folders with 50 files inside each folder.我有 200 个单独的文件夹,每个文件夹中有 50 个文件。 I would like to sort these 200 individual folders into 8 parent folders of 25 subfolders each, whilst retaining all the files inside the subfolders.我想将这 200 个单独的文件夹分类为 8 个父文件夹,每个文件夹有 25 个子文件夹,同时保留子文件夹中的所有文件。

Ideally, the naming structure of the parent folders should follow a sequential pattern based on a phrase (So eg "rvolkov Files 1", "rvolkov Files 2", etc).理想情况下,父文件夹的命名结构应遵循基于短语的顺序模式(例如“rvolkov Files 1”、“rvolkov Files 2”等)。

I have tried to find powershell script for the above, but it seems to only work with files and not folders, so I haven't been able to utilise it ( here )我试图找到上面的 powershell 脚本,但它似乎只适用于文件而不是文件夹,所以我无法使用它( here

How can I do this in Windows 10?如何在 Windows 10 中执行此操作? If it helps, the individual folders are named after barcodes, so the first few digits are the same.如果有帮助,各个文件夹以条形码命名,因此前几位数字相同。

Thank you in advance先感谢您

According to what I assume is your question, this is a possible solution:根据我认为是您的问题,这是一个可能的解决方案:

# 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.

相关问题 如何通过使用父文件夹的名称循环浏览30个文件夹并在每个文件夹中创建4个子文件夹? - How can i loop through 30 folders and create 4 subfolders in each by taking part of the name of the parent folder? 根据子文件夹的最后修改日期对文件夹进行排序 - Sort folders according last modified date of subfolders 使用PowerShell在多个父文件夹中创建子文件夹 - Creating subfolders with PowerShell in multiple parent folders powershell-在多个父文件夹中批量创建子文件夹 - powershell - bulk create of subfolders in multiple parent folders 在特定的多个父文件夹中创建子文件夹 - Creating subfolders in specific, multiple parent folders Windows10 / PowerShell:如何计算文件数,然后按子文件夹分类? - Windows10/powershell: how to count files and then sort them by subfolders? 通过比较 2 个文件夹来区分子文件夹 - Difference in subfolders by comparing 2 folders 将子文件夹中的文件夹/文件递归移动到其父文件夹 - Recursively move folders/files within subfolders to its parent 使用不同的父文件夹 CSV 创建多个子文件夹 - Powershell - Create multiple subfolders with different parent folders CSV - Powershell 删除许多文件夹和子文件夹中的特定文件夹 - Delete specific folders in many folders and subfolders
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM