Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@ $projectfolders = @(
# Loop through each folder and calculate the total size
foreach ($projectfolder in $projectfolders) {
if (Test-Path $projectfolder) {
$folderSize = (Get-ChildItem -Path $projectfolder -Recurse | Measure-Object -Property Length -Sum).Sum
# Store Get-ChildItem results in a variable to optimize performance
$items = Get-ChildItem -Path $projectfolder -Recurse

# Calculate total size
$folderSize = ($items | Measure-Object -Property Length -Sum).Sum
$folderSizeMB = [math]::Round($folderSize / 1MB, 2)
Write-Output "Total size of $projectfolder : $folderSizeMB MB"

# Count files and folders
$fileCount = ($items | Where-Object { -not $_.PSIsContainer }).Count
$folderCount = ($items | Where-Object { $_.PSIsContainer }).Count

# Display information in structured format
Write-Output "Folder: $projectfolder"
Write-Output " Total size: $folderSizeMB MB"
Write-Output " Files: $fileCount"
Write-Output " Folders: $folderCount"
Write-Output ""
}
else {
Write-Output "Folder $projectfolder does not exist."
Write-Output ""
}
}