Files
photo-sorter/remover.py
2024-11-13 08:12:11 -06:00

32 lines
777 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 x.split(".")[-1].lower() in ["db" ,"lrprev" ,"lrv" , "thm", "lrcat", "txt", "xmp"]:
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))