Files
photo-sorter/remover.py
Nico Melone ba6ddfe180 initial
2021-08-23 19:32:35 -05:00

32 lines
770 B
Python

#remove .LRV .lrprev .THM .lrcat
import os
from os.path import isfile, isdir
from datetime import datetime
import time
rootlist = os.listdir()
root = os.getcwd()
def clean(item):
#print(item)
for x in item:
#print(x)
if isfile(x):
#sort the file
if ".db" in x or ".lrprev" in x or ".LRV" in x or ".THM" in x or ".lrcat" in x:
os.remove(x)
elif ".py" in x:
pass
else:
os.chdir(x)
clean(os.listdir())
if os.listdir() == []:
removeable = os.getcwd()
os.chdir("../")
os.rmdir(removeable)
else:
os.chdir("../")
start = time.time()
clean(rootlist)
end = time.time()
print("It took {} secs".format(end - start))