Brainstorming: Folder and File names cleanup script

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
Endeavour79
Posts: 12
Joined: 27 May 2013, 06:07

Brainstorming: Folder and File names cleanup script

Post by Endeavour79 » 27 May 2013, 06:32

:idea: :?: :idea:
This is a brainstorming topic.
:idea: :?: :idea:

I am fairly new to NZBGet V11 and much newer to Python programming but I am willing to try my best to create a nice post processing script.
For most of the downloads I am annoyed by all the different file and folder names with all the tags and additional information in it.

My idea is to create a script that basically walks down folder/subfolder/file level and renames the folder and files, cleaning out all the unnecessary information.
Afterwards, it put's the files into the proper folder.

More graphical:

Code: Select all

WorkFolder:
Downloads\Movies\Sub\Sub1\filename year abcd free xvid.mkv
Download\Games\Free\English\Free Demo gamename.iso
The script should run and strip all the junk, clean up the file names and put the files in an Archive

Code: Select all

Archive Dir:
Archive\Movies\(optinal Sub1 year)\filename.mkv
Archive\Ganes\(optional Gamefolder)\gamename.iso
I am still in concept phase, wondering if:
  • This was done before?
  • Your opinion if this is possible, reasonable or not?
  • Best method on how to determine what strings to remove?
  • What method would you use to configure/control the script (example config file containing (to be removed)words, reading some info from the nzb file, ...)?
  • Your ideas on potential additional features for this script ?
Thank you for your input and constructive feedback!

Cheers, End 8-)

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: Brainstorming: Folder and File names cleanup script

Post by hugbug » 27 May 2013, 07:42

There is clearly a demand for such a script.

As mentioned in topic Feature request: Sorting, there is a python script turbo-sort. This is a standalone program, which for better integration with NZBGet needs to be transformed into a pp-script, in a similar way it was done with Subliminal.

I was planning to work on the transformation in the next weeks but if you could take this job over, I'd be more than happy.

I has contacted the author and he has kindly made few improvements on my request. The improved version is not published yet on web-site (he still works on it) but I would make the transformation (nice word) in a way which would allow an easy update to a newer version of turbo-sort. I was not planning to add any additional features to the script myself and therefore an easy update was an important factor for me.

Tubro-sort is of course not the only way to go. If you don't want to use it as a basis for your script, you can create you own script from scratch. Well, you don't need to do that from scratch actually. You could use GuessIt library to do the difficult part - parsing file names and extracting the movie/series name, episode number etc.

Best method on how to determine what strings to remove?
The script should not think about clearing or removing words. It should keep the worth-while files and delete the rest:
  1. The script scan the download folder and searches for files it can process (video files);
  2. If none video files were found the script exits without doing anything;
  3. If files were found the script moves them into a different (final) location creating subfolders when necessary (series name, season number, etc) and renaming the files according to the scheme defined by the user;
  4. All remaining files in the download folder are removed then as well as the directory itself. A special option for MaxFileSizeToRemove could be implemented to avoid accidental deletion of big files which were not properly detected.
What method would you use to configure/control the script?
Script options of course.

Endeavour79
Posts: 12
Joined: 27 May 2013, 06:07

Re: Brainstorming: Folder and File names cleanup script

Post by Endeavour79 » 27 May 2013, 08:33

Thanks for your ideas. I was more after renaming than deletion of other files.
However, I will have a look at your recommendations!

Sent you a more detailed PM.

jackdoldno7
Posts: 2
Joined: 26 Feb 2014, 18:48

Re: Brainstorming: Folder and File names cleanup script

Post by jackdoldno7 » 26 Feb 2014, 19:11

I made a shell script (python is more robust, but less portable in my opinion) that pretty much does this. I have it dependent on category name. If the nzb is in one of the supported categories, it lists all the files in the download including all subdirectories (just the output of the find command) in the messages section of nzbget, then it searches for specific file extensions and moves those files to the specified directory and deletes anything else that was in there. I found a "DeleteSamples.py" script somewhere and I run that first so the samples are gone if they were there before it runs. I put all sorts of checks in there too like to make sure directories exist, etc. Also, if it finds rar files or DOESN'T find any of the specified file types, it exits without deleting anything because that's a big indicator that something was wrong to begin with. I have it list all the files in the messages section so I know what was deleted. This way I'll see if it ever deletes something I wanted to keep. Then I know to change the script.

I actually use this for two different categories and the final file location is dependent on the category selected. You can choose the path in the webgui because I used nzbget options for either movies or series.

My favorite by far is the email.py that comes with nzbget12. emailing the results with ALL output including pp is just priceless for troubleshooting and an amazing time saver! Thanks everyone at nzbget!

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: Brainstorming: Folder and File names cleanup script

Post by hugbug » 26 Feb 2014, 20:38

The initial request posted in this topic was implemented in pp-script TurboSort, which was later replaced by VideoSort.

From your description I understand your script is designed for slightly other purposes. It is a welcomed addition to the pp-script collection, especially taking into account it is written in bash and can therefore run on systems where python is not available. If you are going to share the script I suggest you to make a separate topic, which will allow you to keep the first post up to date.

jackdoldno7
Posts: 2
Joined: 26 Feb 2014, 18:48

Re: Brainstorming: Folder and File names cleanup script

Post by jackdoldno7 » 27 Feb 2014, 03:24

I forgot about VideoSort... VideoSort can essentially do the same thing. Coming from v0.7.0 I had a lot of manual shell scripts that I've been converting into functional pp scripts when likely a complete change of my methods is what's needed. I was a little trigger happy with my posting since I just finished getting everything to work and his problem seemed real similar to mine. I'll post it sometime soon. Maybe someone will even improve on it... Thanks again

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests