Foldermonitor Issue

Dec 2, 2008
223
2
Canada
Why does only one FOLDERMONITOR command work at a time? Here is an example session:

C:\> FOLDERMONITOR /s "c:\Creative Focus Publishing" /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Monitor 1 100 "CFP-Folder-Handler1" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
C:\> touch "c:\Creative Focus Publishing\eBook\Catalog\Christian\Money - Master or Servant\Money - Master or Servant.epub"
2018-02-01 21:44:21.961 C:\Creative Focus Publishing\eBook\Catalog\Christian\Money - Master or Servant\Money - Master or Servant.epub

C:\> foldermonitor
c:\Creative Focus Publishing CREATED MODIFIED RENAMED (1/FOREVER) Monitor 1 100 "CFP-Folder-Handler1" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"

C:\> foldermonitor /c
C:\> FOLDERMONITOR /s "c:\Indesign Publishing" /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Monitor 1 100 "CFP-Folder-Handler2" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
C:\> touch "c:\Indesign Publishing\Art\Artistic Ideas & Inspirations\About the Artist.indd"
2018-02-01 21:45:45.567 C:\Indesign Publishing\Art\Artistic Ideas & Inspirations\About the Artist.indd

C:\> foldermonitor
c:\Indesign Publishing CREATED MODIFIED RENAMED (1/FOREVER) Monitor 1 100 "CFP-Folder-Handler2" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"

C:\> foldermonitor /c
C:\> FOLDERMONITOR /s "c:\Creative Focus Publishing" /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Monitor 1 100 "CFP-Folder-Handler1" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
C:\> FOLDERMONITOR /s "c:\Indesign Publishing" /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Monitor 1 100 "CFP-Folder-Handler2" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
C:\> touch "c:\Creative Focus Publishing\eBook\Catalog\Christian\Money - Master or Servant\Money - Master or Servant.epub"
2018-02-01 21:46:38.528 C:\Creative Focus Publishing\eBook\Catalog\Christian\Money - Master or Servant\Money - Master or Servant.epub

C:\> touch "c:\Indesign Publishing\Art\Artistic Ideas & Inspirations\About the Artist.indd"
2018-02-01 21:46:50.566 C:\Indesign Publishing\Art\Artistic Ideas & Inspirations\About the Artist.indd

C:\> foldermonitor
c:\Creative Focus Publishing CREATED MODIFIED RENAMED (1/FOREVER) Monitor 1 100 "CFP-Folder-Handler1" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
c:\Indesign Publishing CREATED MODIFIED RENAMED (0/FOREVER) Monitor 1 100 "CFP-Folder-Handler2" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"


I show that both FOLDERMONITOR commands work when they run separately but when executed together and files in both directories are touched, only the first FOLDMONITOR command fires. Does this mean only one FOLDERMONITOR command per session?

Craig
 
May 20, 2008
10,563
78
Syracuse, NY, USA
Here's another example that seems to confirm Craig's observation.
Code:
v:\> del dir1\file1 dir2\file2
Deleting V:\dir1\file1
Deleting V:\dir2\file2
     2 files deleted

v:\> foldermonitor /s v:\dir1 CREATED FOREVER echo %%_folderaction %%_folderfile1 ^> v:\fmlog1.txt

v:\> foldermonitor /s v:\dir2 CREATED FOREVER echo %%_folderaction %%_folderfile1 ^> v:\fmlog2.txt

v:\> foldermonitor
v:\dir1   CREATED   (0/FOREVER)   echo %_folderaction %_folderfile1 > v:\fmlog1.txt
v:\dir2   CREATED   (0/FOREVER)   echo %_folderaction %_folderfile1 > v:\fmlog2.txt

v:\> touch /c v:\dir1\file1
2018-02-02 13:27:05.945  V:\dir1\file1

v:\> touch /c v:\dir2\file2
2018-02-02 13:27:21.124  V:\dir2\file2

v:\> foldermonitor
v:\dir1   CREATED   (1/FOREVER)   echo %_folderaction %_folderfile1 > v:\fmlog1.txt
v:\dir2   CREATED   (0/FOREVER)   echo %_folderaction %_folderfile1 > v:\fmlog2.txt

v:\> type fmlog1.txt
CREATED file1

v:\> type fmlog2.txt
TCC: (Sys) The system cannot find the file specified.
 "V:\fmlog2.txt"
 
May 20, 2008
10,563
78
Syracuse, NY, USA
A question for cgunhouse ... below, what's the stuff after "FOREVER" and before the command "c:\JPSoft\Batches\CFP-Folder-Handler.btm"?
C:\> FOLDERMONITOR /s "c:\Creative Focus Publishing" /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Monitor 1 100 "CFP-Folder-Handler1" "c:\JPSoft\Batches\CFP-Folder-Handler.btm"
 

rconn

Administrator
Staff member
May 14, 2008
11,910
133
Fixed for 22.0.38.

The cause wasn't in the TCC code (which hadn't changed between 20 & 21), it was an overly enthusiastic VS2017 optimizer. I had to mark one of the variables as volatile to prevent the compiler from optimizing away an explicit assignment.
 
Dec 2, 2008
223
2
Canada
A question for cgunhouse ... below, what's the stuff after "FOREVER" and before the command "c:\JPSoft\Batches\CFP-Folder-Handler.btm"?
Hi Vince,

This is a library that I loaded which contains:


Code:
Handler {
  @ECHO OFF
    SETLOCAL
    SET FastTrack=%1
    SET StartupWait=%2
    SET MyTitle=%3
    START %MyTitle /INV /C %4 %5$
    DELAY /M100
    ENDLOCAL
}

Monitor {
  @echo off
  SETLOCAL
  SET DirToMon=%1
  SET FastTrack=%2
  SET DelayTime=%3
  SET HandlerName=%4
  SET HandlerExecutable=%5   
    FOLDERMONITOR /s %1 /E"*.bak" /W100 CREATED MODIFIED RENAMED FOREVER Handler %FastTrack %DelayTime %HandlerName %HandlerExecutable
    ENDLOCAL
}