Page 1 of 1
Read file names / assign category based on nzb filename
Posted: October 28th, 2022, 5:13 pm
by Emmcee
Hello people
I am trying to find a solution to the following problem after a lot of trial and error:
Is there a way that SABnzbd automatically assigns the download to a certain category based on reading the NZB file name and occurrences in it?
An example:
Series.S01E01.nzb
If Sabnzbd detects a NZB in the watched folder that contains "S0" or "E0" in its name, automatically assign this download to the category Series and start downloading.
I am looking forward to your constructive help!
Mama Greetz Emmcee
Re: Read file names / assign category based on nzb filename
Posted: October 29th, 2022, 1:04 am
by sander
I'm not sure if SAB itself can do it, but you certainly can do it with a pre-queue script. See
https://sabnzbd.org/wiki/scripts/pre-queue-scripts
Re: Read file names / assign category based on nzb filename
Posted: October 29th, 2022, 3:33 am
by safihre
See here in the second list how we apply it:
https://sabnzbd.org/wiki/configuration/3.6/categories
Your specific case might indeed require a custom script.
But maybe a better question, why do some jobs need different category? What problem do you have?
Re: Read file names / assign category based on nzb filename
Posted: October 29th, 2022, 4:15 am
by Emmcee
Hello and thank you very much for the great answers! I often load series and movies with always the same name attributes in one watched NZB Folder. These should be assigned automatically and not manually via the dashboard. many greetings from Germany
Re: Read file names / assign category based on nzb filename
Posted: October 29th, 2022, 4:46 am
by jcfp
Emmcee wrote: ↑October 29th, 2022, 4:15 amI often load series and movies with always the same name attributes in one watched NZB Folder.
You can assign categories via the watched folder by putting the nzb file in a subdirectory named after a category.
Re: Read file names / assign category based on nzb filename
Posted: October 29th, 2022, 2:12 pm
by OneCD
jcfp wrote: ↑October 29th, 2022, 4:46 am
You can assign categories via the watched folder by putting the nzb file in a subdirectory named after a category.
Thanks @jcfp, I'll be able to make good use of that.

Re: Read file names / assign category based on nzb filename
Posted: October 30th, 2022, 5:26 am
by safihre
Hmm reading the documentation, I think we should improve the documentation a bit. This functionality isn't really described well in the Categories page, only on the Config page.
Re: Read file names / assign category based on nzb filename
Posted: May 1st, 2024, 3:45 pm
by mantinaut
I'm using the sabnbzd docker container and realized it as follows:
1.) Settings > Special Folders > Scripts Folder > bin
2.) Created the file "obtain-category-by-filename" in /config/bin with the following content:
Code: Select all
#!/bin/bash
# Return parameters
# accept nzb
echo "1"
# do not overwrite job name
echo ""
# no post processing
echo ""
# category
if echo "$SAB_FINAL_NAME$SAB_FILENAME" | --quiet grep --ignore-case --perl-regexp "(s[0-9]+e[0-9]+|s[0-9]+.?complete)"; then
echo "tv"
else
echo "movies"
fi
# no script path
echo ""
# default priority
echo "0"
# do not change group
echo ""
3.) chmod 775 /config/bin/obtain-category-by-filename
4.) Settings > Switches > Pre-queue script > set to "obtain-category-by-filename"
EDIT: @admins the default board preference "Notify me upon replies by default:" should be "yes" I think. I would have almost missed replies
