我有200个个人文件夹与50个文件在每个文件夹内。我想把这200个单独的文件夹分类成8个父文件夹,每个子文件夹有25个子文件夹,同时保留子文件夹中的所有文件。
理想情况下,父文件夹的命名结构应该遵循基于短语的顺序模式(例如"rvolkov Files 1“、"rvolkov Files 2”等)。
我试图为上面的内容找到powershell脚本,但是它似乎只适用于文件而不是文件夹,所以我无法使用它(here)
我如何在Windows 10中做到这一点?如果有帮助,各个文件夹都是以条形码命名的,所以前几个数字是相同的。
提前谢谢你
发布于 2022-09-14 08:01:34
根据我认为是你的问题,这是一个可能的解决办法:
# 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++
}
}https://stackoverflow.com/questions/73713112
复制相似问题