Date format fix

Fix date format in cache clear report
This commit is contained in:
amd64fox
2022-02-15 07:39:17 +03:00
parent 802ce5f300
commit ab8dd8cd3d
2 changed files with 10 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ $day = 7 # Number of days after which the cache is considered stale
try {
If (!(Test-Path -Path $env:LOCALAPPDATA\Spotify\Data)) {
"$(Get-Date -uformat %D %T) Folder Local\Spotify\Data not found" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Folder Local\Spotify\Data not found" | Out-File log.txt -append
exit
}
$check = Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day)
@@ -25,19 +25,19 @@ try {
$sum = $count | Measure-Object -Property Length -sum
if ($sum.Sum -ge 104434441824) {
$gb = "{0:N2} Gb" -f (($check | Measure-Object Length -s).sum / 1Gb)
"$(Get-Date -uformat %D %T) Removed $gb obsolete cache" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Removed $gb obsolete cache" | Out-File log.txt -append
}
else {
$mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb)
"$(Get-Date -uformat %D %T) Removed $mb obsolete cache" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Removed $mb obsolete cache" | Out-File log.txt -append
}
Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item
}
if ($check.Length -lt 1) {
"$(Get-Date -uformat %D %T) Stale cache not found" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Stale cache not found" | Out-File log.txt -append
}
}
catch {
"$(Get-Date -uformat %D %T) $error[0].Exception" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") $error[0].Exception" | Out-File log.txt -append
}
exit

View File

@@ -15,7 +15,7 @@ $day = 7 # Количество дней после которых кеш счи
try {
If (!(Test-Path -Path $env:LOCALAPPDATA\Spotify\Data)) {
"$(Get-Date -uformat %D %T) Папка Local\Spotify\Data не найдена" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Папка Local\Spotify\Data не найдена" | Out-File log.txt -append
exit
}
$check = Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day)
@@ -25,19 +25,19 @@ try {
$sum = $count | Measure-Object -Property Length -sum
if ($sum.Sum -ge 104434441824) {
$gb = "{0:N2} Gb" -f (($check | Measure-Object Length -s).sum / 1Gb)
"$(Get-Date -uformat %D %T) Удалено $gb устаревшего кеша" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Удалено $gb устаревшего кеша" | Out-File log.txt -append
}
else {
$mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb)
"$(Get-Date -uformat %D %T) Удалено $mb устаревшего кеша" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Удалено $mb устаревшего кеша" | Out-File log.txt -append
}
Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item
}
if ($check.Length -lt 1) {
"$(Get-Date -uformat %D %T) Устаревшего кеша не найдено" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Устаревшего кеша не найдено" | Out-File log.txt -append
}
}
catch {
"$(Get-Date -uformat %D %T) $error[0].Exception" | Out-File log.txt -append
"$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") $error[0].Exception" | Out-File log.txt -append
}
exit