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.

How to get true file path from Directory Watcher?

If you have a question or need help, this is the place to be.
Post Reply
Cloud203
Posts: 3
Joined: Sat Aug 16, 2014 7:13 pm

How to get true file path from Directory Watcher?

Post by Cloud203 »

Hello everyone,

I'm a newbie when it comes to Python, but I'm learning..

I'm trying to make an event that watches my Dropbox screenshot directory for new files, and when one is created, take that file path and copy it to the Clipboard. When I try to set the clipboard to {eg.event.payload} of Directory Watch, I get the path, but it isn't quite right... Instead of getting C:\\Documents and Settings\\Cloud\\Desktop\\DROPBOX\\Dropbox\\Screenshots\\ScreenshotFileName.png, I'm getting (u'C:\\Documents and Settings\\Cloud\\Desktop\\DROPBOX\\Dropbox\\Screenshots\\ScreenshotFileName.png',)

The bolded text is what I want removed from the path string, but I'm unsure how to do that. I tried adding a Python script that assigns the Payload to a variable, then snips the first and last two characters... but the script doesn't seem to work and it gives me errors. The script is simply:

Code: Select all

dirtypath = (eg.event.payload)
cleanpath = dirtypath[2:-2]
I have no idea if that's even accurate. Can anyone shed some light on what I'm doing wrong?
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: How to get true file path from Directory Watcher?

Post by Pako »

Code: Select all

dirtypath = (eg.event.payload)
cleanpath = dirtypath[0]
Cloud203
Posts: 3
Joined: Sat Aug 16, 2014 7:13 pm

Re: How to get true file path from Directory Watcher?

Post by Cloud203 »

Thanks! That fixed the error I was having.

This might sound stupid... but how can I get that variable to the clipboard now? The method I'm trying isn't working. In Eventghost, underneath the python script above; I have the "Copy String to Clipboard" Action, and I've input {cleanpath}. When I try running it, it outputs "()".

Am I doing this incorrectly?
Cloud203
Posts: 3
Joined: Sat Aug 16, 2014 7:13 pm

Re: How to get true file path from Directory Watcher?

Post by Cloud203 »

So... I managed to find a solution to my problem, without using any python script at all.

I simply removed the python script, and set the Clipboard action to {eg.event.payload[0]}. This got the "true path" that I was looking to get, without needing to clean it up with the script first. I don't understand why {eg.event.payload[0]} is different from {eg.event.payload}, but it's what I want.

However, if someone wants to clarify what I was doing wrong on my earlier post, I'd still love to learn.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: How to get true file path from Directory Watcher?

Post by Pako »

Cloud203 wrote:... why {eg.event.payload[0]} is different from {eg.event.payload} ...
This is because the plugin Directory Watcher presented observation results in the form of a python tuple.

Pako
Post Reply