Created
June 3, 2023 04:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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