Skip to content

Instantly share code, notes, and snippets.

@john-clark
Created June 3, 2023 04:38
Show Gist options
  • Save john-clark/25d6d9c66b69df8d5a76dd0cc729ec64 to your computer and use it in GitHub Desktop.
Save john-clark/25d6d9c66b69df8d5a76dd0cc729ec64 to your computer and use it in GitHub Desktop.
Sonarr only updates media file dates, run this to fix season and series folder dates.
$dir = get-childitem -path E:\tv -directory -Exclude "*sonar*"
foreach ($series in $dir){
$show = get-item $series
$show_lwt = $show.LastWriteTime
$seasons = get-childitem -directory $series
foreach ($season in $seasons){
$showseason = get-item "$series\$season"
$season_lwt = $showseason.LastWriteTime
$episodes = Get-ChildItem $showseason -filter *.m*
foreach ($episode in $episodes){
$efile = get-item "$series\$season\$episode"
if ($efile | Test-Path) { $episode_lwt = $efile.LastWriteTime }
}
if (!($episode_lwt -eq $season_lwt)) {
Write-Host "Changing $showseason From $season_lwt To $episode_lwt"
$showseason.LastWriteTime = $episode_lwt
}
}
if (!($episode_lwt -eq $show_lwt)) {
Write-host "Changing $show From $show_lwt To $episode_lwt"
$show.LastWriteTime = $episode_lwt
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment