Custom script to duplicate file - help plz!

Hi,

I am trying to convert from sickrage to sonarr, but I don’t have all my custom things done. One thing in could use some assistance with is a custom bash script and how to implement it in sonarr. In sickrage, it ran as the last step of post processing where once the media file was renamed and moved, my script then copied the file to another folder leaving the original in place.

So for example, sickrage placed the file at /mnt/archive and my script “duplicate.sh” runs and copies the file to /mnt/tv as an extra copy. Here is my script.

#!/bin/sh
cp “$1” “/mnt/tv/”

How do I do this in sonarr and in the connect area, what needs to be on/off etc to make it work?

Thank you

I believe that would be:

#!/bin/sh
cp "$sonarr_episodefile_path" "/mnt/tv/"

From the wiki:

In all cases the Environment Variables Sonarr sends will be prefixed with Sonarr and converted to lowercase.

EpisodeFile_Path -> Full path to the episode file

Then under connect you’d add a new custom script with “On Download” and “On Upgrade” switched on (grab and rename both off) and “Path” set to the full path to the script (the browse button will only get you as far as the folder–you need the actual filename, too). If you only want it to work on select shows then add one or more tags to the script, then only shows with that/those tags will call the script.

1 Like

I would recommend using a hard link though, unless it’s on a different drive. It’s quicker and will save space.

Indeed, though /mnt suggested different volumes in this case.

Perhaps hard linking, but falling back to a cp would be best. Something like:

#!/bin/sh
ln "$sonarr_episodefile_path" "/mnt/tv/" || cp "$sonarr_episodefile_path" "/mnt/tv/"