Wish Sonarr would touch the parent show folder on changes

Not sure if this is a feature request or a support request, but I find it very frustrating that Sonarr doesn’t appear to touch the parent show’s folder when new episodes are added. This results in the parent show’s folder being modified potentially weeks ago, even though there is an episode added just last night. Since I tend to look at my show folder ordered by date in order to see what’s new and available for watching, this means I have no way to easily tell if I got anything new.

I’m on OSX so maybe other OSes handle this differently, but apparently (and somewhat understandably) the Mac only considers the actual file contents of a folder when considering if the folder has changed. Changing the contents of a folder within a folder, will update only the modified date of the sub-folder. I believe a simple touch of the parent folder when contents have been altered would be enough to update the modified date, and it would be a tremendously useful thing for anyone who does as I do, and sorts their shows directory by date in order to see “what’s on”.

If there’s already some better way to deal with this, I’m all ears! Thanks. :slight_smile:

You can try an use custom script after import maybe. The variables that you can pipe to the script are in the wiki

Interesting. How would I actually create such a script though? There’s variables listed on that page but no code examples or anything to point me to what language(s) to use, etc. Applescript? Automator?

If you’re aiming at touch folders then I guess the script should be in bash.
I only use bash for my sonarr scripts one for remove source file and other one for sending telegram notifications.
I know other users use python for scripts.

Any chance someone could point me to resources for how to create such a script? I really have no clue where to start.

I just want the series folder touched, which seems like it might be relatively trivial since the series path is available as a variable.

For your issue is not that complex create a file script.sh in OSX

#!/bin/bash
touch "$sonarr_series_path"/datetime

set it to executable with chmod +x script.sh in terminal

In sonarr then in the connect tab add custom script, put the path for the script.sh and set the switches for “on download” and “on upgrade”

That’s awesome! Have set it up, will wait for it to do its thing on my next show download. Thanks so much!

It works like a charm. I knew it should be simple. :wink: Thanks again for the script!

Now that it’s been running for more than a day, I see that it does not always work. Sometimes the script fails to touch the series parent directory. Any idea why that might happen?

Permission issue maybe?
Check what the log says in debug mode when importing

I’ll check the logs but I don’t see how it could be a permissions issue if it works sometimes but not always with all the same paths.

I’m waiting on the show to download to see what happens, but in the meantime… why am I seeing piles of these errors?

Import failed, path does not exist or is not accessible by Sonarr: /Volumes/Media1/Complete Media/The.Player.2015.S01E08.HDTV.x264-FLEET

It’s for all different shows, and all shows that have been previously downloaded and move to my “series” folder. Those episodes aren’t in the location above and they shouldn’t be, as Sonarr has already long since moved them. I have DF turned completely off (set to zero and no path) so why is it automatically trying to import things from that location every minute??

OK here is what I got when it tried to run the touch script:

Message
Unable to send OnDownload notification to: series_touch: ApplicationName='/Users/media/Documents/', CommandLine='', CurrentDirectory='', Native error= Cannot find the specified file

Exception
System.ComponentModel.Win32Exception: ApplicationName='/Users/media/Documents/', CommandLine='', CurrentDirectory='', Native error= Cannot find the specified file
  at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00352] in /private/tmp/source-mono-mac-4.0.0-bug-33585-hotfix/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/System.Diagnostics/Process.cs:1105 
  at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x0008b] in /private/tmp/source-mono-mac-4.0.0-bug-33585-hotfix/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/System.Diagnostics/Process.cs:1169 
  at System.Diagnostics.Process.Start () [0x0002c] in /private/tmp/source-mono-mac-4.0.0-bug-33585-hotfix/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/System.Diagnostics/Process.cs:1179 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
  at NzbDrone.Common.Processes.ProcessProvider.Start (System.String path, System.String args, System.Collections.Specialized.StringDictionary environmentVariables, System.Action`1 onOutputDataReceived, System.Action`1 onErrorDataReceived) [0x0012b] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Processes\ProcessProvider.cs:167 
  at NzbDrone.Common.Processes.ProcessProvider.StartAndCapture (System.String path, System.String args, System.Collections.Specialized.StringDictionary environmentVariables) [0x00011] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Common\Processes\ProcessProvider.cs:199 
  at NzbDrone.Core.Notifications.CustomScript.CustomScriptService.ExecuteScript (System.Collections.Specialized.StringDictionary environmentVariables, NzbDrone.Core.Notifications.CustomScript.CustomScriptSettings settings) [0x00016] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Notifications\CustomScript\CustomScriptService.cs:88 
  at NzbDrone.Core.Notifications.CustomScript.CustomScriptService.OnDownload (NzbDrone.Core.Tv.Series series, NzbDrone.Core.MediaFiles.EpisodeFile episodeFile, System.String sourcePath, NzbDrone.Core.Notifications.CustomScript.CustomScriptSettings settings) [0x00220] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Notifications\CustomScript\CustomScriptService.cs:58 
  at NzbDrone.Core.Notifications.CustomScript.CustomScript.OnDownload (NzbDrone.Core.Notifications.DownloadMessage message) [0x00000] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Notifications\CustomScript\CustomScript.cs:27 
  at NzbDrone.Core.Notifications.NotificationService.Handle (NzbDrone.Core.MediaFiles.Events.EpisodeDownloadedEvent message) [0x000c0] in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Notifications\NotificationService.cs:132 

Cannot find the file? It’s sitting right there in the user’s Documents folder… why wouldn’t it be able to find it sometimes?

Did Sonarr move them? Or were they moved by something else? It has nothing to do with Drone Factory, they’re coming from your download client and Sonarr doesn’t see them as imported (in its history), so its trying to import them.

ApplicationName='/Users/media/Documents/'

What did you set the custom script to, looks like its set to a folder, not something to actually execute.

The files would only ever have been moved by Sonarr.

Yeah Sonarr wouldn’t allow me to select the file, so I thought I was supposed to choose the directory. script.sh doesn’t appear in the file selection “dialog” in Sonarr when I tell it what script to execute.

At the moment the sonarr file browser doesn’t let you pick up files, just folder. So pick up the top folder where the script is, and after the slash type the name of the script. Leave the arguments field empty

Something like this

Ahhhh that explains it. I figured it worked by just picking the top folder, since the “test” passed fine. I’ve manually typed in the script filename now, let’s see if that does the trick.

The strange part is that it worked several times. Seems like it would either work always, or not at all. Weird.

So, now Sonarr is failing to import the show at all after it’s downloaded. The episode is sitting there in my “completed” folder but never gets brought into Sonarr.

Also I still get lots of this error for shows which have long since been downloaded, imported, watched, and deleted:

Import failed, path does not exist or is not accessible by Sonarr: /Volumes/Media1/Complete Media/The.Player.2015.S01E08.HDTV.x264-FLEET

Why am I getting those?

Looks like the remote path is not properly translated. What are the settings in that section?
the Media1 i guess is a remote mount in a nas right?

No, Media1 is a locally mounted drive on the server where Sonarr lives.

The script is definitely not executing, just watched as Sonarr downloaded a new episode of a show, properly imported it, and the parent folder was not touched. I then realized that the user’s /Documents folder was only executable to the user, and I’m not sure what user Sonarr runs as, so I made it executable for all, but it still doesn’t work.

I also still get loads of those errors for shows that are long gone. And I just re-downloaded an episode I’d already watched and deleted, in order to test the custom script handling, and Sonarr didn’t even import the episode at all let alone run the custom script.