Hi
I┬┤m using directory watcher to trigger an event, but I want this only to happen with a certain file extension (.png). Any help?
Thanks!
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Directory watcher only triggers if a certain file extension
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Directory watcher only triggers if a certain file extens
Python Script content:Pako
Code: Select all
from os.path import splitext
pld = eg.event.payload
fl = pld[0]
ext = splitext(fl)[1].lower()
if ext == '.png':
eg.TriggerEvent("%s.%s" % (eg.event.suffix, "Png"), prefix=eg.event.prefix, payload = pld)Re: Directory watcher only triggers if a certain file extens
It didn┬┤t work for me, the event is not filtered by extension.
Am I supposed to edit something in the script? I┬┤m sorry, but my python knwoledge is null
Am I supposed to edit something in the script? I┬┤m sorry, but my python knwoledge is null
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Directory watcher only triggers if a certain file extens
There is no need to edit anything.z3us wrote:Am I supposed to edit something in the script?
If the file type is .png, so in this case, a new event will be triggered.
Actions that need to do you have to put in another macro and assign new event to this macro.
Is that clear now?
Pako
Re: Directory watcher only triggers if a certain file extens
Yes, it┬┤s clear now, thanks
But no event is triggered
But no event is triggered
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Directory watcher only triggers if a certain file extens
On the contrary, I see that you do not understand.z3us wrote:Yes, it┬┤s clear now, thanks
The Python Script should not be placed below the DirectoryWatcher.Created.Png event, but below the DirectoryWatcher.Created event.
Below the DirectoryWatcher.Created.Png event has to be placed something else (but I do not know what you do you intend to do with the file).
Pako
- Attachments
-
- PngFilter2.png (8.43 KiB) Viewed 2289 times