Files
useful-scripts/clear-spotify-cache.ps1

28 lines
1.0 KiB
PowerShell

# Description: This script fixes Spotify playlist caching issues.
# get spotify path - might be different, i installed thru ms store
$spotifyBasePath = Join-Path $env:LOCALAPPDATA "Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0\LocalState\Spotify\Users"
if (Test-Path $spotifyBasePath) {
# i had multiple users, loop thru all of them
$userDirs = Get-ChildItem -Path $spotifyBasePath -Directory -Filter "*-user"
foreach ($userDir in $userDirs) {
# primary.ldb is a folder, not a file for some reason
$ldbPath = Join-Path $userDir.FullName "primary.ldb"
if (Test-Path $ldbPath -PathType Container) {
try {
Remove-Item -Path $ldbPath -Recurse -Force
Write-Host "Deleted: $ldbPath"
} catch {
Write-Warning "Failed to delete $ldbPath: $_"
}
} else {
Write-Host "No primary.ldb folder found at $ldbPath"
}
}
} else {
Write-Warning "Spotify user directory not found at $spotifyBasePath"
}