Page 2 of 4

Re: WatchFolder()

Posted: 17 Feb 2016, 20:33
by dsewq1LYJ
Damn it...It is freaking useful !

Re: WatchFolder()

Posted: 08 Mar 2016, 13:03
by VarunAgw
It is executing callback function twice for me. WatchFolder("C:\Apps\file", "sdasd", false, 16). Any idea why it is happening?

Re: WatchFolder()

Posted: 09 Mar 2016, 03:05
by just me
Called twice with the same action for the same file? Also, what is causing the change of the file times?

Re: WatchFolder()

Posted: 13 Mar 2016, 07:29
by DocMAX
WatchFolder("C:\Videos", "MyUserFunc"), WatchFolder("C:\Music", "MyUserFunc")

The second folder doesnt work!

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

Posted: 14 Mar 2016, 05:53
by just me
Hi DocMAX,

I found a bug and fixed it!

Thanks for reporting and your persistency! ;)

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

Posted: 16 Mar 2016, 14:05
by DocMAX
thank you / danke!

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

Posted: 27 Jul 2016, 05:19
by VarunAgw
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.

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

Posted: 28 Nov 2016, 17:23
by egocarib
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.

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

Posted: 29 Nov 2016, 03:51
by just me
Thanks egocarib, you're right. It will be fixed soon.

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

Posted: 30 Nov 2016, 06:25
by just me
Fixed! Thanks again!

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

Posted: 03 Dec 2016, 13:07
by carno
Thanks for the update! WatchFolder() is one the most useful scripts of all time.

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

Posted: 10 Jan 2017, 10:23
by GlockMane
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!

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

Posted: 11 Jan 2017, 07:05
by just me
Isn't the file reported twice, once as 'added' and once as 'modified'?

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

Posted: 12 Jan 2017, 08:56
by GlockMane
Hi "just me" ;)

I only get following Action IDs:

1
2
4

Modified has to be "3".. Thanks for help :)

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

Posted: 12 Jan 2017, 09:02
by just me
What do you get if you don't move the file after action 1 (added) in case the file's size is zero?

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

Posted: 12 Jan 2017, 09:07
by GlockMane
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..

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

Posted: 12 Jan 2017, 09:15
by glockmane
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..

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

Posted: 12 Jan 2017, 11:06
by just me
Which options do you pass to WatchFolder() in Watch?

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

Posted: 02 Feb 2017, 03:07
by r2997790
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

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

Posted: 02 Feb 2017, 04:06
by just me
WatchFolder wrote:Disadvantages (objective):
  • No filter options.
So you have to check the file extensions within the UserFunction.