[英]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.