added vs code
This commit is contained in:
71
Visual Studio Code/vscode-cleanup.ps1
Normal file
71
Visual Studio Code/vscode-cleanup.ps1
Normal file
@@ -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."
|
||||
Reference in New Issue
Block a user