i'm trying to create a script with python that creates sample folder if a sample file exists and the move the file to folder (also for proof and subs). i'm using python, but i'm fairly new to programming. there seem to be a function to automatically delete these files, but not to create the folders like the original release? :\
anyway, here is my code:
and here is the result:
Code: Select all
import os import sys import shutil workDir = os.environ['SAB_COMPLETE_DIR'] print(workDir) for root, dirs, files in os.walk(workDir): for f_name in files: if f_name.endswith('.mkv'): sampleDir = workDir + '/Sample/' os.mkdir(sampleDir) shutil.move(f_name, sampleDir) sys.exit(0)
so the scripts creates the folder and seem like it tries to move, but then it doesn't. is my code off, or could this be a permissions thing? i'm not sure how it works since i think the incoming folder on the array is mounted in the docker container.
Code: Select all
/data/Joe.Pera.Talks.With.You.S01E01.720p.HDTV.x264-MiNDTHEGAP Traceback (most recent call last): File "/usr/lib/python3.8/shutil.py", line 788, in move os.rename(src, real_dst) OSError: [Errno 18] Invalid cross-device link: 'joe.pera.talks.with.you.s01e01.720p.hdtv.x264.sample-mtg.mkv' -> '/data/Joe.Pera.Talks.With.You.S01E01.720p.HDTV.x264-MiNDTHEGAP/Sample/joe.pera.talks.with.you.s01e01.720p.hdtv.x264.sample-mtg.mkv' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/admin/clean_supportfiles.py", line 12, in <module> shutil.move(f_name, sampleDir) File "/usr/lib/python3.8/shutil.py", line 802, in move copy_function(src, real_dst) File "/usr/lib/python3.8/shutil.py", line 432, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "/usr/lib/python3.8/shutil.py", line 261, in copyfile with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: FileNotFoundError: [Errno 2] No such file or directory: 'joe.pera.talks.with.you.s01e01.720p.hdtv.x264.sample-mtg.mkv'
any help would be much appreciated