Page 1 of 1

[REQUEST] Moving a file while unpacking

Posted: 23 Feb 2019, 02:09
by Person5729
I'd appreciate help with a script, I'm a newb so please expect silly errors.

I'm trying to work around DirectUnpack creating the sub-folder called "_unpack" while it's unpacking the file to "completed / NZB NAME / _unpack"

I've tested manually moving the unpacked file while it's still writing, and it continues to write. I presume it's possible to write a script that just moves the continuously writing file a directory above. I need the file in "completed / NZB NAME".

Code: Select all

#!/usr/bin/env python
### NZBGET SCAN SCRIPT

import os.path
import time
import shutil

foldername=os.path.splitext(NZBNP_NZBNAME)[0]
folder="/downloads/completed/" + foldername

while not os.path.exists(folder):
    time.sleep(1)
	
while not os.path.exists(folder + "/_unpack/"):
    time.sleep(1)
	
while not len(os.listdir(folder + "/_unpack/") ) == 0:
    time.sleep(1)
	
files = os.listdir(folder + "/_unpack")

for f in files:
    shutil.move(folder + "/_unpack/" + f, folder)
Thanks for any help. :)