Script not working

Hi guys,

I have this script
#!/usr/bin/env python
import glob
import os
directory=‘C:/Users/Marce/Desktop/New folder/PNG2/’
os.chdir(directory)
files=glob.glob(‘*.jpg’)
for filename in files:
os.unlink(filename)

It is working properly when I run in a Text DAT but it does not work on execute dat. Ayone know why

What kind of execute DAT?
CHOP, Parameter, Panel, DAT, Execute?

What’s the event when you’re trying to run this script?

Chop

Every 2 min I want to run this script

Tks

Try removing the hashbang line at the top. You shouldn’t need it.

One way to do this would be to use a timer CHOP.

The callbacks in the timer restarts the timer at the completion of the cycle, and calls the script in the text_script DAT.

You’ll need to start the timer in order to get this running, and set the duration of the timer to the length of seconds you want.

base_every_2_minutes.tox (982 Bytes)

I see you’ve got a good example to go with, just want to add a note about why your script might not be working.

Is the script you showed the entirety of the text in your CHOP Execute DAT? If that’s the case, it is the cause of your problem. Execute DATs have defined callbacks, the contents of your script needs to be inside that callback, otherwise it’ll only execute once when the DAT loads up. You can see what the defined callbacks are if you put down an Execute DAT by itself. If you create it via the output of another DAT, then its default contents are overridden.