News: 0.5.3 Final is out!  | Return to SABnzbd.org | Contribute to SABnzbd+ | Donors July 29, 2010, 02:22:08 PM
Welcome, Guest. Please login or register.
Did you miss your activation email?
*

[Windows] Don't put downloaded files in subfolders
Pages: [1]
  Print  

  [Windows] Don't put downloaded files in subfolders
Author Message
GHDpro
Newbie
*
Posts: 1


View Profile
« on: November 07, 2009, 08:29:17 AM »

Hello,

I have recently rediscovered Usenet downloading after using BT almost exclusively for a few years.

When I tried Usenet downloading through NZB a while back I used NZB-O-Matic Plus, which works great but of course only does downloading, while sabnzbd does so much more.

One annoyance I encountered with sabnzbd however is that it puts the contents of every downloaded NZB file in it's own subfolder in your download folder. As I mostly download single MKV/AVI files as single NZB files that get's annoying because you end up with lots of folders with 1 file in it.

Now I'm not sure if anyone already wrote a script that solves this issue, but if there isn't one yet, here is the one I wrote:

Code:
@echo off

for /f "tokens=*" %%c in ('dir/b/a-d %1 ^| find /v /c "::"') do set filecount=%%c

if (%filecount% LEQ 5) (
cd /d %1
for /f "tokens=*" %%f in ('dir /a-d /b') do if not exist "..\%%f" (
echo Moving %%f...
move "%%f" ".."
)
cd ..
echo Deleting folder...
rd %1
) else (
echo To many files to move, aborting...
)

Basically this script will count the number of files in the subfolder. If there are 5 or less files in the folder, it'll move them to the parent folder (=root download folder). After all files have been moved it tries to remove the subfolder itself (which should be empty).

The effective result is that your root download folder will contain all downloaded files and no subfolders.

The script won't overwrite a file in the root download folder if the file already exists. In that case the duplicate file remains in the subfolder which won't get removed. The reason for the 5 file limit is to avoid moving (and potentially mixing) large collections of files.

Anyway, I'm not sure if anyone else finds this script useful, but I hope you like it.
Logged
Aburobal73
Newbie
*
Posts: 5

[url=http://russian-brides-best.com/]belarus girl[/url]


View Profile WWW
« Reply #1 on: November 16, 2009, 10:30:04 AM »

Lightroom does work with JPEGs.

Are the files in the directory you imported to with Lightroom?
Logged

threeclaws
Newbie
*
Posts: 2


View Profile
« Reply #2 on: December 07, 2009, 03:40:01 AM »

So do I just copy the script into a text document and then give the file a .pl extension?

edit - I think I figured out that it should be a batch file.
« Last Edit: December 10, 2009, 09:46:44 PM by threeclaws » Logged
chris1712
Newbie
*
Posts: 3


View Profile
« Reply #3 on: December 11, 2009, 03:10:26 PM »

Fantastic. How can I change it to rename the file to the nzb report name?

Whats a good batch guide, I'm a C programmer by trade so linux I'm happy with but batch looks so messy.
Logged
asemev
Newbie
*
Posts: 4


View Profile
« Reply #4 on: December 11, 2009, 05:33:01 PM »

hi guys,

i am total newbie and have no idea of how to write a script in mac os x. would you guys be willing to help me?
i also want the files to be moved to a single folder and no be kept under subfolders...
its so strange that there isnt such a setting in sabnzbd in the first place...

thanks for your help in advance.
Logged
seesaw
Newbie
*
Posts: 4


View Profile
« Reply #5 on: February 13, 2010, 06:37:11 AM »

Hi !

Exactly what I was looking for, thank you very much for coding that !

The only problem is that I can't get it to work.

I created a Script folder in my SABnzbd directory and put that folder's adress in the SABnzbd config/folder page.
I copied/pasted you code in a txt folder that I renamed script1.exe, went to config/switches and selected script1.exe under Default user script.

But it doesn't work, any ideas ?
Logged
doubledrat
Release Testers
Full Member
*
Posts: 226


View Profile
« Reply #6 on: February 13, 2010, 07:47:59 AM »

scripts are not .exe

rename is whatever.cmd (or .bat)
Logged
seesaw
Newbie
*
Posts: 4


View Profile
« Reply #7 on: February 13, 2010, 08:08:10 AM »

scripts are not .exe

rename is whatever.cmd (or .bat)

Very nive of you, it's working fine, thanks a lot !
Logged
seraulu1
Newbie
*
Posts: 1


View Profile
« Reply #8 on: February 21, 2010, 10:41:01 AM »

Yeah that's good thankslearn hypnosis
Logged
gitar
Newbie
*
Posts: 3


View Profile
« Reply #9 on: March 17, 2010, 01:31:55 PM »

I'm pretty new to python, but I made a script for this. Maybe someone could need it, took me a while to figure it out. Tongue

It will move all files from the download folder (src) one folder up (dst), checks if the file (s) is (are) there and then deletes the download folder(src).

Not sure, but the script could work on different operating systems, I only tested it on win 7 with python 2.6.4.

Code:
import os,sys,shutil

src = sys.argv[1]
head, tail = os.path.split(src)
dst = head

for file in os.listdir(src):
  shutil.move(os.path.join(src,file),dst)
print "File moved ..."

if os.path.exists(dst + '\\' + file):
  shutil.rmtree(src)
  print "Directory removed ..."
  print "*** All done - Have fun ***"
else: print "Error: File not in destination directory"
Logged

Pages: [1]
  Print  
 

Jump to: