[REQUEST] Moving a file while unpacking

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
Person5729
Posts: 1
Joined: 22 Feb 2019, 22:22

[REQUEST] Moving a file while unpacking

Post by Person5729 » 23 Feb 2019, 02:09

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. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests