Another delete script request

Come up with a useful post-processing script? Share it here!
Post Reply
Posts: 5
Joined: September 21st, 2014, 4:03 am

Another delete script request

Post by Viktor112 » February 10th, 2017, 4:19 am

Good morning all!

I was wondering if someone managed to get rid of files by size.

This is the issue: I download a movie, filetype MKV but there is almost always an commercial added as a MP4.
Normally I would say put that extension to the 'Cleanup List' but sometimes the MP4's are needed and I don't want to have it to remove all the times.
I would like to have Sabnzbd or some other way to get rid of the files by a XX filesize.

I did find the special setting: 'movie_rename_limit - 100M - The minimum size of a file to trigger file renaming in the Sort functions' is ignored or misunderstood by me.
The behavior now is when I download TED mkv, movie file is 8gb and the commercial is mp4 and 50mb, I would expect that the renaming part of my sorting would not enable on the commercial.
But the result is: ted.mkv and ted.mp4.

What to do to get this thing sorted ?

Thanks in advance.

Ps. I'm on W10 - SABNZBD Version: 1.1.0 [8abcf08]

Posts: 1
Joined: November 2nd, 2017, 9:51 am

Re: Another delete script request

Post by RikPet » November 2nd, 2017, 9:54 am

So i had the same issue with this.

I created a post processing script with some help from the internet and especially fire_starr from Reddit. There was 1 error in his example which i fixed.

You can use the following one which will delete any mkv, avi or mp4 file which is less than 100 MB.

Put a file in your scripts folder with the .py extension and assign it to your category. The content of the .py file should be:

Code: Select all

import sys
import os

    (scriptname,directory,orgnzbname,jobname,reportnumber,category,group,postprocstatus,url) = sys.argv
        # are we testing only?
        directory = sys.argv[1]
        print "No commandline parameters found"

# continue script

# Your code goes here
files = os.listdir(directory)

# Size in MB
size = 100

for f in files:
    # Add or remove extensions here:
    if os.path.isfile(os.path.join(directory, f)) and f.endswith((".mkv",".avi",".mp4")):
        if os.path.getsize(os.path.join(directory, f)) / (1024.0*1024.0) < size:
            # Removes files with the above extensions less than 100MB of size
            os.remove(os.path.join(directory, f))

# Success code

Posts: 6
Joined: September 15th, 2016, 8:55 pm

Re: Another delete script request

Post by Howitzer » November 3rd, 2017, 9:15 am

You are saying "commercial" but do you mean "sample"? Have you tried just deleting anything with "sample" in the file name?

Post Reply