до: папка с названием "Сериалы" после: "Сериалы [9,33 GB ↓]
заранее спасибо за помощь.
- Вложения
Код: Выделить всё
Get-ChildItem 'C:\Films' | Where-Object {$_.PsIsContainer} | Rename-Item -NewName {
$sum = " [{0:F2} GB]" -f ((Get-ChildItem $_.fullname -Force -Recurse | Measure-Object Length -Sum).Sum/1gb)
$_.fullname + $sum.replace(".",",")
} -PassThru -WhatIfКод: Выделить всё
Get-ChildItem -LiteralPath 'C:\Films' | Where-Object {$_.PsIsContainer} | Foreach {
$sum = (" [{0:F2} GB]" -f ((Get-ChildItem -LiteralPath $_.fullname -Force -Recurse | Measure-Object Length -Sum).Sum/1gb)).replace(".",",")
if($_.name -match " \[.+ GB]"){
if ($matches[0] -ne $sum){
$_.MoveTo(($_.fullname -replace [regex]::Escape($matches[0]),$sum))
}
}
else {
$_.MoveTo($_.fullname + $sum)
}
}


Но всё равно спасибо за совет.