Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Created July 8, 2023 15:22
Show Gist options
  • Save Hashbrown777/47e1b1bb45b74cf899de279df8381109 to your computer and use it in GitHub Desktop.
Save Hashbrown777/47e1b1bb45b74cf899de279df8381109 to your computer and use it in GitHub Desktop.
free up space on my c drive
cd $env:LOCALAPPDATA
(
'Ubisoft*',
'Grip',
'Evil*',
'ride3',
'Squad*',
'Remnant',
'Mordhau',
'Dead*',
'Rockstar*',
'Gas *',
'Dungeon*',
'Chivalry*',
'Space*',
'mxgp5',
'GOG*',
'FLiNG*',
'Back4*',
'Rocket*',
'SpeedF*'
) | gi | &{ Param($to)
Begin {
$to = $to | Get-Item -ErrorAction Stop
if ($to -isnot [System.IO.DirectoryInfo]) { throw $to.FullName }
$to = $to.FullName -replace '(?<!\\)$','\'
}
Process {
if (($_ | Get-Item -ErrorAction SilentlyContinue).Count -eq 1) {
$_ = $_ | Get-Item
}
else {
$_ = Get-Item -LiteralPath $_ -ErrorAction Stop
}
if (($_.Parent, $_.Directory).FullName -ne $PWD) {
throw ($_.Parent, $_.Directory).FullName
}
$_ | Move-Item -ErrorAction Stop -Destination $to
$_ = $_.Name
New-Item -type Junction -name $_ -value "$to$_" -ErrorAction Stop
}
} 'D:\Hashbrown\LocalAppData'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment