WatchFolder() - updated on 2016-11-30

Post your working scripts, libraries and tools
dsewq1LYJ
Posts: 114
Joined: 26 Aug 2014, 23:21

Re: WatchFolder()

17 Feb 2016, 20:33

Damn it...It is freaking useful !
VarunAgw
Posts: 22
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

Re: WatchFolder()

08 Mar 2016, 13:03

It is executing callback function twice for me. WatchFolder("C:\Apps\file", "sdasd", false, 16). Any idea why it is happening?
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder()

09 Mar 2016, 03:05

Called twice with the same action for the same file? Also, what is causing the change of the file times?
DocMAX
Posts: 2
Joined: 21 Feb 2015, 05:19

Re: WatchFolder()

13 Mar 2016, 07:29

WatchFolder("C:\Videos", "MyUserFunc"), WatchFolder("C:\Music", "MyUserFunc")

The second folder doesnt work!
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-03-14

14 Mar 2016, 05:53

Hi DocMAX,

I found a bug and fixed it!

Thanks for reporting and your persistency! ;)
DocMAX
Posts: 2
Joined: 21 Feb 2015, 05:19

Re: WatchFolder() - updated on 2016-03-14

16 Mar 2016, 14:05

thank you / danke!
VarunAgw
Posts: 22
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

Re: WatchFolder() - updated on 2016-03-14

27 Jul 2016, 05:19

Sorry! I completely forgot to check this thread.

> Called twice with the same action for the same file? Also, what is causing the change of the file times?

I think yes. If I modified content of a file and save it once, it was raising event twice for some unknown reasons. I used it long time ago, so I am not very sure either.

I ended up using a timer to record event time and ignoring the very frequent ones.
egocarib
Posts: 100
Joined: 21 May 2015, 18:21

Re: WatchFolder() - updated on 2016-03-14

28 Nov 2016, 17:23

There seems to be a leak in the "**END" section. The handle isn't closed appropriately here:

Code: Select all

      For D In WatchedFolders
         If D Is Not Integer
            DllCall("CloseHandle", "Ptr", D.Handle)
D is the key in the above code, and D.Handle is always null. The handle is actually stored as a subkey on the value - so it should rather be something like:

Code: Select all

      For key, D In WatchedFolders
         If key Is Not Integer
            DllCall("CloseHandle", "Ptr", D.Handle)
Other than that, thanks for sharing. This was very useful.
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-03-14

29 Nov 2016, 03:51

Thanks egocarib, you're right. It will be fixed soon.
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-11-30

30 Nov 2016, 06:25

Fixed! Thanks again!
carno
Posts: 207
Joined: 20 Jun 2014, 16:48

Re: WatchFolder() - updated on 2016-11-30

03 Dec 2016, 13:07

Thanks for the update! WatchFolder() is one the most useful scripts of all time.
GlockMane

Re: WatchFolder() - updated on 2016-11-30

10 Jan 2017, 10:23

I want to copy/move a file after it was written to some Folder. How can I make this script recognize if a file was completely written? Problem is, it moves the file and size is 0kb.. Thenks and best regards!
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-11-30

11 Jan 2017, 07:05

Isn't the file reported twice, once as 'added' and once as 'modified'?
GlockMane

Re: WatchFolder() - updated on 2016-11-30

12 Jan 2017, 08:56

Hi "just me" ;)

I only get following Action IDs:

1
2
4

Modified has to be "3".. Thanks for help :)
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-11-30

12 Jan 2017, 09:02

What do you get if you don't move the file after action 1 (added) in case the file's size is zero?
GlockMane

Re: WatchFolder() - updated on 2016-11-30

12 Jan 2017, 09:07

I don't move it anymore while testing.. If I create an empty Word doc I get:

"1" (word doc added)

Then I open it and get another

"1" (temporary file added)

Then I type something and save the document I get:

"1"
"4"
"4"
"2"

Then I Close the document and get:

"2" (temporary file deleted)

I couldn't get a "3", whatever I try..
glockmane
Posts: 1
Joined: 12 Jan 2017, 09:10

Re: WatchFolder() - updated on 2016-11-30

12 Jan 2017, 09:15

Small example:

- I create a new *.docx (right click in Folder, New..) -> "1" (doc added)
- I open the *.docx -> "1" (temp file created)
- I type something and hit save -> "1", "4", "4", "2"
- I Close it -> "2" (temp file deleted)

No matter what I try, couldn't get a "3".. :/

Edit:

Sorry for double post, didn't realize that it had to be approved by a mod..
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-11-30

12 Jan 2017, 11:06

Which options do you pass to WatchFolder() in Watch?
r2997790
Posts: 51
Joined: 02 Feb 2017, 02:46

Re: WatchFolder() - updated on 2016-11-30

02 Feb 2017, 03:07

Hi there.

I was wondering if someone can help me understand how to make a small modification to this wonderful script!

I'd like to be able to watch for 2 file types (*.mobi and *.epub) in the defined watch folder.

I have the script running but no idea how to add a condition to only watch for those two file types?

Does anyone have any suggestions and a copy snippet they could share? I'm learning and this function would be a huge help and very instructive!

Many thanks
R
just me
Posts: 6551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WatchFolder() - updated on 2016-11-30

02 Feb 2017, 04:06

WatchFolder wrote:Disadvantages (objective):
  • No filter options.
So you have to check the file extensions within the UserFunction.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 58 guests