Need help with a script please

Come up with a useful post-processing script? Share it here!
Post Reply
jcalton88
Newbie
Newbie
Posts: 3
Joined: October 31st, 2009, 4:55 am

Need help with a script please

Post by jcalton88 »

Currently, I use a script to move files out of the folders they are in to the parent directory.
EXAMPLE:
D:\TV\New Shows\Supernatural.s05e05.xvid\Supernatural.s05e05.xvid.avi  to
D:\TV\New Shows\Supernatural.s05e05.xvid.avi

The reason for this is I use another program that monitors that folder for new shows and moves them into their series/season folders and gathers all available metadata for them. The problem is, if the show resides in a subfolder, the program thinks it is a new "series" and doesn't move it. So I use a post processing script that looks like this:

Code: Select all

@echo off
cd /D "%1"
ren *.avi %1.avi
move *.avi ..
cd ..
rd /S /Q %1
This script works great, but the only problem is if a show doesn't happen to get downloaded in a subfolder like the example, the show gets moved into the main directory(D:\TV) and the program doesn't see it then either. Also, the "new shows" folder gets deleted.

So what I want, is something extra in the script, possibly a "IF" parameter? That checks to see if the parent directory is "New Shows" and if so, to not move the file and exit the script, but if the directory is not new shows, to complete the script.

I've tried adding

Code: Select all

@echo off
cd /D "%1"
IF %1 == New Shows (exit) Else (
ren *.avi %1.avi
move *.avi ..
cd ..
rd /S /Q %1)
But that doesn't seem to work, possibly my syntax is off, can someone provide some pointers?
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: Need help with a script please

Post by switch »

Do you make use of TV sorting in SABnzbd at all?

That can be used to not put downloads in their own folders, such as with the following string:

Code: Select all

%sn/Season %s/%sn - S%0sE%0e - %en.%ext
jcalton88
Newbie
Newbie
Posts: 3
Joined: October 31st, 2009, 4:55 am

Re: Need help with a script please

Post by jcalton88 »

The program I use to gather metadata only automatically gets the data if it moves the episodes as well, or else I'd love to make use of Sab's sorting. Thats why I am using this script.

Metabrowser, the program I use, is designed to look into one folder for new shows, move them to the appropriate folder, and gather metadata and episode images automatically, placing them in the appropriate  places as well. It has the functionality to get missing data for all folders, BUT...I've had bad experiences with that so I don't let it, lol.
substyle
Newbie
Newbie
Posts: 30
Joined: December 12th, 2008, 2:40 pm

Re: Need help with a script please

Post by substyle »

jcalton i use metabrowser as well i think i have seen you on those forums. If you use the TV sorting feature, and point metabrowser's tv directory to the same directory that sabnzbd downloads the tv category to, you will be set. I am doing that and it has worked for me for since metabrowser started supporting tv series meta data.
jcalton88
Newbie
Newbie
Posts: 3
Joined: October 31st, 2009, 4:55 am

Re: Need help with a script please

Post by jcalton88 »

I may make a 0-byte replica of my tv directory and try that. Last time I gave MetaBrowser free reign over my TV directory I ended up with a huge mess. For instance, Spongebob(for my kids) was renamed some german version of peewee herman and it took forever to get that straightened back out, :-D
substyle
Newbie
Newbie
Posts: 30
Joined: December 12th, 2008, 2:40 pm

Re: Need help with a script please

Post by substyle »

That is strange. However, the sabnzbd tv sorting feature sorts as [main tv directory]/Series Name/Season #/Episodes which is the exact same format metabrowser has used which is why it [should] pick it all up properly as a tv series (and hopefully the right one). Therefore you should be able to skip the dropbox feature and let sabnzbd handle it (I would also let sabnzbd handle episode renaming). But honestly in the multitude of releases that came out over the past year I must say I have not tried the majority ever since the features I asked for were implemented. Certain releases have been nothing but trouble for me and you might have just happened to give it control of the folder during a buggy release. I know when he was releasing new builds every day sometime around april I had some serious headaches getting the TV sorting to work with this method. I'm almost positive that is what happened to you. I am using Beta 8.12.09 now and it is stable as a rock.
Squidy2391
Newbie
Newbie
Posts: 4
Joined: January 18th, 2010, 1:44 pm

Re: Need help with a script please

Post by Squidy2391 »

Maybe you should use the command 'For /r ... Do ... '. Check my post on extracten iso and img files.

For /r searches a folder and it subdirs and does the action you want. For example:
FOR /r %1 %%G IN (*.avi) DO "copy %%G to c:\new shows\".
rocking
Newbie
Newbie
Posts: 1
Joined: January 20th, 2010, 11:36 pm

Re: Need help with a script please

Post by rocking »

Its seem informative keep it up i will come back with solution if i can. ;)
Post Reply