Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
I had a user ask me to help him write a script which would make symbolic links to newly downloaded files. These symbolic links would then be used by Handbrake on his Apple Silicon Mac (wicked fast in transcoding!), to transcode these new downloads.
Additionally the original (downloaded) filename should stay the same so importing a transcode file would be easy to manually import (maintaining quality, release group, etc).
Initially this seemed a challenge until I found out that Sonarr has the option to run a custom scrip after importing new episodes.
In Sonarr, go to "Settings" -> "Connect" -> "+" -> "Custom Script"
Enter a "Name" so you know what it's for.
Select on what events your custom scripts needs to run. In our example: on Import (downloaded or manually imported) and on Upgrade.
In the "Path" box enter the location and filename of the script you'd like to run. Note that the script needs to run on the same machine (in this case: the NAS) where Sonarr is running.
You can make this file just and empty file initially, and enter the file path and click "Test" to make sure the script can be found etc.
Where ${sonarr_episodefile_scenename} is the original filename, but unfortunately without file extension. Next, ${sonarr_episodefile_sourcepath} holds the new filename with extension. To grab only the extension we use ${sonarr_episodefile_sourcepath##*.}.
- We only want downloads (new and upgrades). Manual imports should be skipped!
This means that the source path should match the downloads folder or part of that name, so in our example the name should include "nzbget" in the original file path. If is doesn't include "nzbget" then we can skip it as it's most likely a manual import.
All combined; this is what I came up with (suitable for Linux or macOS environment - may work different under Windows):
#!/bin/bash
nzbget_path_portion="nzbget"
# Skip all files that do NOT come from NZBGet
if ! [[ "${sonarr_episodefile_sourcepath}" =~ ${nzbget_path_portion} ]]; then
exit
fi
#original downloaded name
ln -s "${sonarr_episodefile_path}" "/share/Downloads/Media Files/Sonarr - New arrivals/${sonarr_episodefile_scenename}.${sonarr_episodefile_sourcepath##*.}"
All files in "/share/Downloads/Media Files/Sonarr - New arrivals/" will now be symbolic links to newly downloaded or upgraded episodes (skipping manual imports), which can be transcoded with Handbrake or other tools. The symbolic links can be deleted or moved without affecting the original files. Of course opening one of these, editing, say in a video editor, and saving it again WILL change the original files.
If you'd like to make a dump of all known variables provided by Sonarr (and the Linux environment), add something like this to the beginning of your script (before the "exit")
# All environment vars:
env > "/share/Downloads/Media Files/envdump.txt"
Or if you want to test/add a single variable, for example:
# Single environment var:
echo "$sonarr_episodefile_scenename" >> "/share/Downloads/Media Files/envdump.txt"
Security Awareness Tip of the Day Great resource to make you online-life more secure - definitely some great tips here and a recommended read.
0xED - Hex Editor Compact, fast and very flexible Hex (hexadecimal) editor for MacOS.
PreLoaders Handy little online tool to generate preload images (spinners).
Ubuntu Ubuntu is probably one of the most used Linux distro's out there. Very well supported and a great Linux distro
XMedia Recode Excellent tool for Windows users to convert pretty much any video format to any other video format, including some helpful options like removing unwanted tracks.
XSlimmer Awesome tool to get back some of the wasted harddisk space by removing unused application stuff. Highly recommended!
Links Page These and more of our favorite links can be found on the Links Page.
squirclenomore-v1.0.2-macos.dmgDate: 2025-11-29 - Size: 5.5 MBmacOS Tahoe applies a very ugly Squircle jail to application icons - SquircleNoMore removes these and resets the normal application icon.
RenameMyTVSeries-2.3.12-GTK-Linux-x64-static-ffmpeg.tar.xzDate: 2025-10-06 - Size: 78.3 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle comes with (large) static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.12-QT5-Linux-x64-static-ffmpeg.tar.xzDate: 2025-09-28 - Size: 78.3 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle comews with rather large static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.12-QT5-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-09-28 - Size: 1.9 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
RenameMyTVSeries-2.3.12-GTK-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-09-28 - Size: 1.9 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
Amazon Ads
Support us by doing your shopping at Amazon.com, either click the link, or click one of the links below …
You can also sponsor us through these Amazon offerings:
Please consider disabling your ad blocker for our website.We rely on these ads to be able to run our website.You can of course support us in other ways (see Support Us on the left).