From bafe78e4d15178369c6ae5843e89d5077d42153d Mon Sep 17 00:00:00 2001 From: AlienLogic Date: Wed, 17 Dec 2025 13:21:51 +0100 Subject: [PATCH] added vs code --- Visual Studio Code/vscode-cleanup.ps1 | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Visual Studio Code/vscode-cleanup.ps1 diff --git a/Visual Studio Code/vscode-cleanup.ps1 b/Visual Studio Code/vscode-cleanup.ps1 new file mode 100644 index 0000000..71ecb86 --- /dev/null +++ b/Visual Studio Code/vscode-cleanup.ps1 @@ -0,0 +1,71 @@ +param ( + [switch] $Confirm, + [switch] $WhatIf +) + +Function PrettifyFileSize($bytes) { + switch ($bytes) { + { $_ -gt 1PB } { return '{0,6:0.00} PB' -f ($_ / 1PB) } + { $_ -gt 1TB } { return '{0,6:0.00} TB' -f ($_ / 1TB) } + { $_ -gt 1GB } { return '{0,6:0.00} GB' -f ($_ / 1GB) } + { $_ -gt 1MB } { return '{0,6:0.00} MB' -f ($_ / 1MB) } + { $_ -gt 1KB } { return '{0,6:0.00} kB' -f ($_ / 1KB) } + default { return '{0,7:0} B' -f $_ } + } +} + +Function GetDirSize($path) { + return [int64] (Get-ChildItem $path -Recurse -Force | Measure-Object Length -Sum).Sum +} + +$allDirs = +"$env:LocalAppData\Microsoft\vscode-cpptools\ipch", +"$env:AppData\Code\Cache", +"$env:AppData\Code\CachedData", +"$env:AppData\Code\CachedExtensions", +"$env:AppData\Code\CachedExtensionVSIXs", +"$env:AppData\Code\Code Cache", +"$env:AppData\Code\Crashpad", +"$env:AppData\Code\logs", +"$env:AppData\Code\Service Worker\CacheStorage", +"$env:AppData\Code\Service Worker\ScriptCache", +"$env:AppData\Code\User\History", +"$env:AppData\Code\User\workspaceStorage", +"$env:UserProfile\.vscode-server\data\CachedExtensions", +"$env:UserProfile\.vscode-server\data\CachedExtensionVSIXs", +"$env:UserProfile\.vscode-server\data\logs", +"$env:UserProfile\.vscode-server\data\User\History", +"$env:UserProfile\.vscode-server\data\User\workspaceStorage" + +$dirsData = @() + +foreach ($path in $allDirs) { + if (Test-Path -Path $path) { +# $row = '' | select Path, Size + $row = '' | Select-Object Path, Size + $row.Path = $path + $row.Size = PrettifyFileSize(GetDirSize($path)) + $dirsData += $row + } +} + +Write-Host $($dirsData | Format-Table | Out-String) + +if (!$Confirm -and ($(Read-Host "Confirm to clear? [y/N]") -ne 'y')) { + Write-Host "Quit" + exit +} + +foreach ($item in $dirsData) { + $target = "$($item.Path)\*" + Write-Host "Clean up ($($item.Size)): $($item.Path)" + $params = @{ + Path = $target + Recur = $true + Force = $true + WhatIf = $WhatIf + } + Remove-Item @params +} + +Write-Host "Cleanup is done."