I need to set up a script that watches a folder for files of a certain type. Ive made this code but i was wondering if there is a better way?
import os
def listAppleseedFiles(directory_path):
directory_entities = os.listdir(directory_path)
files = []
appleseed_files = []
for entity in directory_entities:
file_path = os.path.join(directory_path, entity)
if os.path.isfile(file_path):
if os.path.splitext(file_path)[1] == '.appleseed':
appleseed_files.append(file_path)
return appleseed_files
while True:
for file in listAppleseedFiles('/dir_name'):
doSomething()