I have scoured many questions and tried many suggestions but I just can't seem to get something simple to work. Essentially I would like to run my script on a loop. If a file is present print and repeat. If file is not present sleep for 19 minutes and then run script again. I am able to get the "if" portion to work fine when a file is present. When no file is present nothing happens. I am also completely lost on making it loop.
import os, shutil
import glob
import time
source = 'C:/File Location/Files'
files = os.listdir(source)
files = glob.iglob(os.path.join(' C:/File Location/Files ', "*.pdf"))
for file in files:
if os.path.isfile(file):
time.sleep(30)
print ("Success")
else:
time.sleep(1140)