48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
import os
|
|
import random
|
|
from multiprocessing import Pool
|
|
import sys
|
|
sys.path.append('/home/thebears/Seafile/Designs/ML')
|
|
|
|
#rtpath = '/srv/ftp/hummingbird/2021'
|
|
rtpath = os.path.abspath(sys.argv[1])
|
|
rtpath = os.path.abspath('/srv/ftp/hummingbird/2021/')
|
|
|
|
didir = list()
|
|
for di,dnames, fns in os.walk(rtpath):
|
|
numbers = di.split('/')[-3:]
|
|
if all([n.isnumeric() for n in numbers]):
|
|
didir.append(di)
|
|
|
|
|
|
def list_files(path):
|
|
for file in os.listdir(path):
|
|
if os.path.isfile(os.path.join(path, file)):
|
|
yield file
|
|
|
|
|
|
for cdir in didir:
|
|
|
|
|
|
|
|
|
|
|
|
files = [x for x in list_files(cdir)]
|
|
|
|
|
|
todelete = list()
|
|
for y in files:
|
|
if 'trimmed' not in y:
|
|
ff = os.path.splitext(y)
|
|
fcheck = os.path.join(cdir, ''.join([ff[0],'_trimmed',ff[1]]))
|
|
if os.path.exists(fcheck):
|
|
todelete.append(fcheck)
|
|
|
|
to_purge = set()
|
|
for de in todelete:
|
|
if os.path.exists(de.replace('_trimmed','')):
|
|
to_purge.add(de)
|
|
|
|
for y in to_purge:
|
|
os.remove(y)
|