#目标文件夹
$scrfile = "d:\test"
#起始目录名
$directory = 0
#1825361100
#76547428
#判断当目录的文件数大于0时while循环为真
while( (dir -Path $scrfile -Filter *.eml ).count -gt 0)
{
#起始目录名为1
$directory++
#建立目录
New-Item -Path "d:\$directory" -ItemType Directory -ErrorAction Stop
#累加大小变量
$length = 0
#dir配合where-object移动文件到新目录,记录大小,当大小达到指定大小,跳出管道.
dir -Path $scrfile -Filter *.eml |Where-Object{
$objName = $_.Name
$_.moveto("d:\$directory\$objName")
$length += $_.length
if($length -gt 1825361100)
{
continue
}
}
}