• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Documentation Foldmonitor vs Documentation

Dec 2, 2008
212
2
Canada
#1
I created a .btm to test the parameters of FOLDERMONITOR based on my understanding of the documentation for it. The file contains:

Code:
foldermonitor /c

foldermonitor c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED FOREVER echo (1) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED FOREVER echo (2) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Batches c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED FOREVER echo (3) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Batches /E"c:\jpsoft\Batches\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (4) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (5) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Batches c:\jpsoft\Startup /E"c:\jpsoft\Batches\*.bak" /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (6) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2


After running the .BTM file if I execute FOLDERMONITOR, I get:


c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (1) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (2) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Batches c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (3) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (4) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (5) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Batches c:\jpsoft\Startup /E"c:\jpsoft\Batches\*.bak" /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (6) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2​

Now I use an editor that makes a backup (.bak extension) of file and then save the new version. So let us save test.btm in “c:\jpsoft\Startup” and here is the results:


(2) DELETED 1 c:\jpsoft\Startup test.btm.bak
(2) RENAMED 2 c:\jpsoft\Startup test.btm
(2) RENAMED 3 c:\jpsoft\Startup test.btm.bak
(2) MODIFIED 4 c:\jpsoft\Startup test.btm.bak
(2) CREATED 5 c:\jpsoft\Startup test.btm
(2) MODIFIED 6 c:\jpsoft\Startup test.btm
(2) MODIFIED 7 c:\jpsoft\Startup test.btm
(2) MODIFIED 8 c:\jpsoft\Startup test.btm​


The editor actually does a lot to backup and save, but of all the foldmonitor commands only,

foldermonitor c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED FOREVER echo (2) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2​

worked.

The documentation says:

If you want to monitor multiple conditions for a file or folder, put them into a single FOLDERMONITOR command. FOLDERMONITOR creates a separate thread for each FOLDERMONITOR command, so if you have multiple commands you will be wasting CPU time, RAM, and risk having command executed simultaneously in different threads.

Based on this, we should have got:

(3) DELETED 1 c:\jpsoft\Startup test.btm.bak
(3) RENAMED 2 c:\jpsoft\Startup test.btm
(3) RENAMED 3 c:\jpsoft\Startup test.btm.bak
(3) MODIFIED 4 c:\jpsoft\Startup test.btm.bak
(3) CREATED 5 c:\jpsoft\Startup test.btm
(3) MODIFIED 6 c:\jpsoft\Startup test.btm
(3) MODIFIED 7 c:\jpsoft\Startup test.btm
(3) MODIFIED 8 c:\jpsoft\Startup test.btm​


The documentation says:

/E


Filename to be excluded. If you want to exclude multiple files, use multiple /E options. If you want to exclude a file in a specific subdirectory, the filename should include the relative path from the folder name. The name can include wildcards.


So we should have got:

(5) RENAMED 1 c:\jpsoft\Startup test.btm
(5) CREATED 2 c:\jpsoft\Startup test.btm
(5) MODIFIED 3 c:\jpsoft\Startup test.btm
(5) MODIFIED 4 c:\jpsoft\Startup test.btm
(5) MODIFIED 5 c:\jpsoft\Startup test.btm
(6) RENAMED 1 c:\jpsoft\Startup test.btm
(6) CREATED 2 c:\jpsoft\Startup test.btm
(6) MODIFIED 3 c:\jpsoft\Startup test.btm
(6) MODIFIED 4 c:\jpsoft\Startup test.btm
(6) MODIFIED 5 c:\jpsoft\Startup test.btm​

The "/E" issue was fixed:
19.02.38 FOLDERMONITOR - fixed a problem with /E (not matching the documentation)

Does this mean there is still an issue with "/E"?
It also appears that multiple directories references on a single command doesn't work.
 
Dec 2, 2008
212
2
Canada
#2
Tried changing the order of the multiple directories as follows :

Code:
foldermonitor /c
foldermonitor c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED FOREVER echo (1) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED FOREVER echo (2) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED FOREVER echo (3) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Batches /E"*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (4) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup /E"*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (5) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup c:\jpsoft\Batches /E"*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (6) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Batches /E"c:\jpsoft\Batches\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (7) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (8) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2
foldermonitor c:\jpsoft\Startup c:\jpsoft\Batches /E"c:\jpsoft\Batches\*.bak" /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED FOREVER echo (9) %%_folderaction %%_foldercount %%_foldername %%_folderfile1 %%_folderfile2

When I do a FOLDERMONITOR, I get:

c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (1) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (2) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (3) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (4) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (5) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup c:\jpsoft\Batches /E"*.bak" CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (6) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Batches CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (7) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (8) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
c:\jpsoft\Startup c:\jpsoft\Batches /E"c:\jpsoft\Batches\*.bak" /E"c:\jpsoft\Startup\*.bak" CREATED DELETED MODIFIED RENAMED (0/FOREVER) echo (9) %_folderaction %_foldercount %_foldername %_folderfile1 %_folderfile2
Notice that the "/E" part for 4, 5, 7 and 8 is missing.

When I save Test.btm, I now get:

(3) DELETED 1 c:\jpsoft\Startup test.btm.bak
(9) DELETED 1 c:\jpsoft\Startup test.btm.bak
(6) DELETED 1 c:\jpsoft\Startup test.btm.bak

(2) DELETED 1 c:\jpsoft\Startup test.btm.bak
(3) RENAMED 2 c:\jpsoft\Startup test.btm
(9) RENAMED 2 c:\jpsoft\Startup test.btm
(6) RENAMED 2 c:\jpsoft\Startup test.btm
(2) RENAMED 2 c:\jpsoft\Startup test.btm
(3) RENAMED 3 c:\jpsoft\Startup test.btm.bak
(9) RENAMED 3 c:\jpsoft\Startup test.btm.bak
(6) RENAMED 3 c:\jpsoft\Startup test.btm.bak

(2) RENAMED 3 c:\jpsoft\Startup test.btm.bak
(3) MODIFIED 4 c:\jpsoft\Startup test.btm.bak
(9) MODIFIED 4 c:\jpsoft\Startup test.btm.bak
(6) MODIFIED 4 c:\jpsoft\Startup test.btm.bak

(2) MODIFIED 4 c:\jpsoft\Startup test.btm.bak
(3) CREATED 5 c:\jpsoft\Startup test.btm
(9) CREATED 5 c:\jpsoft\Startup test.btm
(6) CREATED 5 c:\jpsoft\Startup test.btm
(2) CREATED 5 c:\jpsoft\Startup test.btm
(3) MODIFIED 6 c:\jpsoft\Startup test.btm
(9) MODIFIED 6 c:\jpsoft\Startup test.btm
(6) MODIFIED 6 c:\jpsoft\Startup test.btm
(2) MODIFIED 6 c:\jpsoft\Startup test.btm
(3) MODIFIED 7 c:\jpsoft\Startup test.btm
(9) MODIFIED 7 c:\jpsoft\Startup test.btm
(6) MODIFIED 7 c:\jpsoft\Startup test.btm
(2) MODIFIED 7 c:\jpsoft\Startup test.btm
(3) MODIFIED 8 c:\jpsoft\Startup test.btm
(9) MODIFIED 8 c:\jpsoft\Startup test.btm
(6) MODIFIED 8 c:\jpsoft\Startup test.btm
(2) MODIFIED 8 c:\jpsoft\Startup test.btm
So that is looking better, but I don't think that the highlighted items should be there.
The second directory appears to be ignored, only the first directory appears to be monitored.
 
#3
In (3) and (6), it seems that you have specified TWO folders. I don't think you can do that. When I try, there's no error, but only the first one specified is monitored.

Code:
foldermonitor c:\jpsoft\Batches c:\jpsoft\Startup <====????

foldermonitor c:\jpsoft\Batches c:\jpsoft\Startup <====????
 
Dec 2, 2008
212
2
Canada
#4
I'm not sure, foldermonitor, seems to indicate it might.

I'm not always sure how to read the documentation:

If you want to monitor multiple conditions for a file or folder, put them into a single FOLDERMONITOR command. FOLDERMONITOR creates a separate thread for each FOLDERMONITOR command, so if you have multiple commands you will be wasting CPU time, RAM, and risk having command executed simultaneously in different threads.
 
#5
Multiple "conditions", not multiple folders. I'm familiar with the function used to monitor a directory. You only get to specify one handle (to a directory to be watched), though it can be told to also monitor (all) subdirectories of that directory.
 
Dec 2, 2008
212
2
Canada
#6
I know what it says but "/E" didn't show up for the single folder, basically I was throwing everything in there to see what worked and what did. I don't think that "/E" is working.
 
#7
There's something funny about "/E". When I do this
Code:
v:\> foldermonitor v:\ /E"*.foo" CREATED DELETED MODIFIED RENAMED FOREVER echo %%_folderfile1
and from another instance,
Code:
v:\> del abc.txt
Deleting V:\abc.txt
  1 file deleted

v:\> touch /c abc.txt
2016-03-17 23:12:10.280  V:\abc.txt
I get no report from FOLDERMONITOR. I would have thought the default would be to include everything that's not excluded. But in this case I can't get FOLDERMONITOR to report anything at all.

OTOH, if I
Code:
foldermonitor v:\ /I"*" /E"*.foo" CREATED DELETED MODIFIED RENAMED FOREVER echo %%_folderfile1
and, in another instance,
Code:
v:\> touch /c abc.txt
2016-03-17 23:14:00.230  V:\abc.txt

v:\> del abc.txt
Deleting V:\abc.txt
  1 file deleted

v:\> del abc.foo
Deleting V:\abc.foo
  1 file deleted

v:\> touch /c abc.txt
2016-03-17 23:18:31.720  V:\abc.txt

v:\> touch /c abc.foo
2016-03-17 23:18:48.163  V:\abc.foo
it works as expected, reporting on abc.txt and not reporting on abc.foo.
 
#8
I've been trying to use FOLDERMONITOR, with zero success. I started with trying to get a MSGBOX to appear if a certain file is created, and that didn't work, despite the file being created. So I dropped back to the absolute basic case of setting up a monitor event for a created file and creating the file, and that doesn't work either.

So obviously I'm doing something wrong, but I've gone over the documentation and for the life of me, I can't see what's wrong with this:

[d:\dir]ver
TCC 18.00.18 Windows 7 [Version 6.1.7601]

[d:\dir]foldermonitor
No folders/files are being monitored.

[d:\dir]foldermonitor %_CWD% /I Final.txt CREATED DELETED MODIFIED RENAMED FOREVER copy Final.txt \temp

[d:\dir]echo this is a test > Final.txt

[d:\dir]dir /km Final.txt
6/27/2016 5:54p 16 Final.txt

[d:\dir]dir /km \temp\
TCC: (Sys) The system cannot find the file specified.
"D:\temp\*"

[d:\dir]foldermonitor

D:\dir Final.txt CREATED DELETED MODIFIED RENAMED (0/FOREVER) copy Final.txt \temp
Does anything see anything wrong with this? I've tried all sorts of permutations, but nothing seems to work. Is there. All of the %_FOLDERxxxxx% variables are empty, as I'd expect. Is there some hook that's missing, or some initialization I need to do prior to invoking FOLDERMONITOR?
 
Top Bottom