simple script to move files after processing

Come up with a useful post-processing script? Share it here!

simple script to move files after processing

Postby mfacer » September 9th, 2010, 5:09 pm

I've been looking around at the scripts available on the forum, but they all look a little too advanced!

My files are downloaded to /incoming then based on the category I assign then are put in to a folder, for example incoming/tv or incoming/movie etc.

I then want to run a script to take the category I assign (so I know if it's a move, tv, anime etc) and move it to a completely different folder. Everything seems to be run from the incoming folder though.

eg:

if category = "movie-animated", then move to 192.168.0.X/Movies/Animations
if category = "tv", then move to 192.168.0.X/TV

is the above possible? I have mounted the IP address (NAS drive) but forget the name I gave it! (so this begs another question, can I move to an IP or does it have to be a mounted location?)

I am using amahi (on Fedora 12)

Thanks for any information.
mfacer
Newbie
Newbie
 
Posts: 4
Joined: September 9th, 2010, 5:02 pm

Re: simple script to move files after processing

Postby rascalli » September 10th, 2010, 5:35 am

I use the following on UBUNTU.

This moves files to my movie folder , deletes files , and also merges CD1 & CD2.

Maybe it can help you.

Basicly you can do the MOVIE processing for different categories , just copy paste & make the changes

SABNZBD+ Postprocessing Movies & TV
User avatar
rascalli
Moderator
Moderator
 
Posts: 666
Joined: January 18th, 2008, 1:30 am
Location: Bossche bollen land

Re: simple script to move files after processing

Postby mfacer » September 10th, 2010, 6:48 am

Thanks for that - looks perfect. Do I just make the changes (eg target dirs) then save?
What do I save it as... and then I assume I just point the post processing field in SABNZBD to that file?

thanks very much
mfacer
Newbie
Newbie
 
Posts: 4
Joined: September 9th, 2010, 5:02 pm

Re: simple script to move files after processing

Postby sweetie » September 10th, 2010, 10:27 am

Alternatively, you could use:

Code: Select all
#!/bin/bash

if [ "$5" = "movie-animated" ]; then
  mv -fv "$1" /mnt/point/Movies/Animations
elif [ "$5" = "tv" ]; then
  mv -fv "$1" /mnt/point/tv
elif [ "$5" = "etc" ]; then
  etc.
fi



You'll need to find the mount point, rather than use the IP.
Last edited by sweetie on September 10th, 2010, 11:32 am, edited 1 time in total.
sweetie
Full Member
Full Member
 
Posts: 117
Joined: May 10th, 2009, 11:47 am

Re: simple script to move files after processing

Postby rascalli » September 10th, 2010, 2:17 pm

mfacer wrote:Thanks for that - looks perfect. Do I just make the changes (eg target dirs) then save?
What do I save it as... and then I assume I just point the post processing field in SABNZBD to that file?

thanks very much


yep make the cahnges and then save , as there is no webui or something to make the changes.

It is a bash script , so save it as name.sh , and indeed set this for the categories you like as post-process scripit , make sure the file is 777
User avatar
rascalli
Moderator
Moderator
 
Posts: 666
Joined: January 18th, 2008, 1:30 am
Location: Bossche bollen land

Re: simple script to move files after processing

Postby mfacer » September 12th, 2010, 10:13 am

Thanks guys.... I added the script, but when it tried to process, I got the following error.

Cannot run script /var/spool/sabnzbd/incoming/scripts/sort.sh

But there are no other error messages. Any idea what's up? here's the code I have used

Code: Select all
#!/bin/bash

if [ "$5" = "movies" ]; then
  mv -fv "$1" /mnt/homer/Movies
elif [ "$5" = "tv" ]; then
  mv -fv "$1" /mnt/homer/TV
fi


[edit] I've just chmod to 777 to see if that helps, I forgot to do that as instructed... [/edit]
Last edited by mfacer on September 12th, 2010, 10:15 am, edited 1 time in total.
mfacer
Newbie
Newbie
 
Posts: 4
Joined: September 9th, 2010, 5:02 pm

Re: simple script to move files after processing

Postby racso » January 7th, 2011, 8:19 am

I currently use this script on a OSX Mac.

Code: Select all
#!/bin/bash

if [ "$5" = "movies" ]; then
  mv -fv "$1" "/Volumes/External HD/Media/Movies"
elif [ "$5" = "tv" ]; then
  mv -fv "$1" "/Volumes/External HD/Media/TV"
fi


Note that you can change the "/Volume/../.././" bit to whatever you like. Even (mounted) network drives!

If you want to see your mounted disks go to the "Finder" menu -> "Go" -> "Go to folder". Then type "/Volumes/" (without the quotes) and voila! 
racso
Newbie
Newbie
 
Posts: 4
Joined: January 7th, 2011, 8:09 am

Re: simple script to move files after processing

Postby CloudDweller » February 6th, 2011, 10:58 am

Okay I'm using OS X and I'm having a problem getting my TV Shows moved to my network drive.  I've set everything as per the previous posts and the download is being moved, but it's not moving the show folder, just the season.  For example

Download looks like: Macintosh HD/TV/24/Season 04/24 - S04E01
The moved file looks like: Network Drive/TV/Season 04/24 - S04E01
What I want it to look like: Network Drive/TV/24/Season 04/24 - S04E01

Does anyone have any ideas why the TV Show's folder isn't being moved from my downloads folder, just the contents?

Also, I use the same script to move my movies to my network drive and I have a similar problem.

Download looks like: Macintosh HD/Movies/Avatar (2009)
The moved file looks like: Network Drive/Movies/Movies/Avatar (2009)
What I want it to look like: Network Drive/Movies/Avatar (2009)

For some reason its creating a sub folder called movies which I don't want, so if anyone has any ideas on either problem I'd really appreciate some advice.
Last edited by CloudDweller on February 6th, 2011, 12:21 pm, edited 1 time in total.
CloudDweller
Newbie
Newbie
 
Posts: 16
Joined: October 27th, 2010, 1:31 pm

Re: simple script to move files after processing

Postby CloudDweller » February 8th, 2011, 6:06 am

Sorry to bump, but can anybody help me.
CloudDweller
Newbie
Newbie
 
Posts: 16
Joined: October 27th, 2010, 1:31 pm

Re: simple script to move files after processing

Postby Mar2zz » February 8th, 2011, 12:24 pm

It looks like you setup Sabnzbd so that it decides for itself if it's a movie or a tvshow, so you dont need the if statement, this should be enough:
mv -fv "$1" "Network Drive"

But I don't really see why you use a script to move files to your networkdrive. You can use sabnzbd to move everything in categorie movies to \\NameOfNetworkdrive\\Movies en in categorie tv shows to \\networkdrive/\TV
Last edited by Mar2zz on February 8th, 2011, 1:24 pm, edited 1 time in total.
User avatar
Mar2zz
Jr. Member
Jr. Member
 
Posts: 85
Joined: February 4th, 2011, 9:30 am

Re: simple script to move files after processing

Postby CloudDweller » February 8th, 2011, 5:19 pm

When I set a download going I manually set which category it belongs to.  I have tried not using the script and just entered "\\Linkstation\\TV" into the Folder/Path under the TV category and although it does remove the download from my MacBook's hard drive it doesn't appear on my network drive.  Could you please tell me what I'm doing wrong?
CloudDweller
Newbie
Newbie
 
Posts: 16
Joined: October 27th, 2010, 1:31 pm

Re: simple script to move files after processing

Postby Mar2zz » February 9th, 2011, 8:40 am

Sabnzbd logs what happened with your download, you can find that under history and click the + sign to see what happened.

Since sab is on a mac, you could try this:
Map the networkdrive on your mac (use google for that). I don't own a Mac and advise everyone to do not so too ;-), it's a digital prison.

or use smb://nameofnetworkdrive/foldername as a location where Sab should move the files to. When it's passwordprotected share you use smb://username:password@nameofnetworkdrive/share .

Maybe you should use \\Linkstation\TV (only one slash before the folder you want to map)
User avatar
Mar2zz
Jr. Member
Jr. Member
 
Posts: 85
Joined: February 4th, 2011, 9:30 am

Re: simple script to move files after processing

Postby CloudDweller » February 9th, 2011, 5:12 pm

Thanks Mar2zz for you help so far.  After managing to get Sabnzbd to move my files to my network drive without using a script, I've come across a problem that others seem to be having.  Sabnzbd is post processing directly to my network drive causing a huge amount of network traffic plus its taking forever to extract (over 5 hours for a 10GB download).  After this process it then cleans up left over files.  I would prefer it to post process the files first and then move.

Looking around the forums it looks like this is only possible using a script.  So I wondered if we could revisit my original post and try to see why Sabnzbd is not leaving the show name folder behind and just moving the season folder and it's contents and also look at why it's creating a movie folder on my network share instead of simply moving the files to the root.

I really appreciate your help so far.  I'm new to using Sabnzbd's more advanced features and would love t get this working.
Last edited by CloudDweller on February 10th, 2011, 5:36 am, edited 1 time in total.
CloudDweller
Newbie
Newbie
 
Posts: 16
Joined: October 27th, 2010, 1:31 pm

Re: simple script to move files after processing

Postby CloudDweller » February 10th, 2011, 3:24 am

Just an update.  I created a new script called MoveTest.sc which contained the following:

mv -fv "$1" /Users/Chris/Desktop"

This way I could eliminate the possibility of an issue with my network drive or Sabnzbd differentiating between movies and TV shows using a script.  After a couple of tests with TV shows and Movies, manually selecting the categories for each, here are my results.  My downloads prior to running the script looked like this:

TV Show
/Users/Chris/Downloads/TV/24/Season 3/24 -S03E05.mkv

Movie
/Users/Chris/Downloads/Movies/Avatar (2009).mkv

Once the script was run, this is is what I was left with:

TV Shows
/Users/Chris/Downloads/TV/24
/Users/Chris/Desktop/TV Shows/Season 3/24 - S03E05.mkv

Movie
/Users/Chris/Downloads/
/Users/Chris/Desktop/Movies/Movies/Avatar (2009).mkv

The "TV Shows" and "Movies" folders on my desktop were created by me prior to download.

So for some reason Sabnzbd is either not moving the entire directory structure when its dealing with TV Shows, just the season folder (Season 1) with the TV show folder (24) left behind.  Or with movies its moving the category folder (Movies), which I don't want.

Mar2zz could you please help as I don't know what I'm doing wrong.
Last edited by CloudDweller on February 10th, 2011, 9:39 am, edited 1 time in total.
CloudDweller
Newbie
Newbie
 
Posts: 16
Joined: October 27th, 2010, 1:31 pm

Re: simple script to move files after processing

Postby Mar2zz » February 10th, 2011, 1:24 pm

Try this:
Code: Select all
#!/bin/bash

for folders in $1 #### for all folders inside the downloadpath do the following
do
newpath=$(echo $folders | sed "s#/Users/Chris/Downloads/#/Network Drive/#g") #### create new path by replacing local dirs with networkdir
mkdir -p "$newpath" || #### make the newdir if it doesn't exist
mv -f "$folders/*.*" "$newpath"
#rm -Rf $1
done


This is what it does in steps:
1. $1 is downloadpath by Sabnzbd (this includes enddirectory TV or Movies in your setup)
2. for al folders inside the downloadpath do the following:
3. newpath=virtually replace local directorys with networkdirectory in the echo (sed is a search and replace tool) | means it's a "piped" command
4. make the new directorys on networkdrive it they do not exist or.... || means OR and && means AND
5. move all files in the localfolder to the networkstation. (mv -f means it doesn't whines if files are going to be replaced) You could uncomment it to make that work.

Debugoutput:
Code: Select all
mars@Lynxtop:~$ ./sabtest.sh
+ DIR=/home/mars/Disk2/TVShows/Weeds
+ for folders in '$DIR'
++ sed s#/home/mars/Disk2/#/home/mars/test/#g
++ echo /home/mars/Disk2/TVShows/Weeds
+ newpath=/home/mars/test/TVShows/Weeds
+ mkdir -p /home/mars/test/TVShows/Weeds
+ mv -f /home/mars/Disk2/TVShows/Weeds/weeds.s06e12.hdtv.xvid-fqm.en.srt /home/mars/Disk2/TVShows/Weeds/weeds.s06e12.hdtv.xvid-fqm.nl.srt /home/mars/Disk2/TVShows/Weeds/weeds.s06e12.hdtv.xvid-fqm.org /home/mars/test/TVShows/Weeds


then optional, remove the downloadpath.
User avatar
Mar2zz
Jr. Member
Jr. Member
 
Posts: 85
Joined: February 4th, 2011, 9:30 am

Next

Return to Post-Processing Scripts