TechieGuy12 / FileWatcher

A file and folder monitor that can send notifications, perform actions, or execute a command when a file or folder is changed.
MIT License
106 stars 27 forks source link

Add support for 'Command' WorkingDirectory #42

Open MusicMan74 opened 4 months ago

MusicMan74 commented 4 months ago

Hello and thanks for FileWatcher!

I am currently using FW to monitor file changes and run an EXE on a change.

My issue is that the command line executable I'm running uses the "WorkingDirectory". I can work around this limitation if I launch FW.exe from the desired "WorkingDirectory", i.e.

C:\Users\User\Desktop\Repo1>c:\Portable\FileWatcher\fw.exe

However, if I need to monitor files from two different folders (i.e. define two configuration xml nodes), I can't run FW from both folder locations :) [Unless I run two instances of FW?]

Therefore, does it make sense/possible to add a 'WorkingDirectory' XML 'Command' sub-node in the configuration file which would be applied when the EXE is run?

i.e.

`

C:\Users\User\Desktop\Repo1 Change C:\Users\User\Desktop\Repo1 C:\Program Files\TortoiseHg\thg.exe commit "[exactpath]" C:\Users\User\Desktop\Repo2 Change C:\Users\User\Desktop\Repo2 C:\Program Files\TortoiseHg\thg.exe commit "[exactpath]"

`

Thanks in advance for your time :)

TechieGuy12 commented 4 months ago

I have added the working directory tag to the 1.5.2 beta release: https://github.com/TechieGuy12/FileWatcher/releases/tag/1.5.2-beta.1.

Check to see if it works for you?

MusicMan74 commented 4 months ago

Hi,

Thanks for responding. I tried the new binary (SHA-1 28eee7595623815bcf3004ebbcae3bd05c7dfe66) and updated my config file but the tag does not seem to take effect...

`

C:\Users\Greg\Desktop\Repo2 Change C:\Users\Greg\Desktop\Repo2 C:\Program Files\TortoiseHg\thg.exe commit "[exactpath]"

`

I tried with and without trailing backslash, ( i.e. Repo2\ ) but no luck Is my syntax incorrect?

I can't see what you changed since there is nothing to compare in commit 3ab7185; also the source code zips in the 1.5.2-Beta1 assets are identical to the release from 2023.12.29...

Could you add logging to confirm WorkingDirectory is being read correctly and/or actually used?

Again, thanks for your time :)

TechieGuy12 commented 4 months ago

I forgot to mention the tag in the XML file is workingDirectory with a capital 'D'.

The commit for the beta is in the develop branch.

MusicMan74 commented 4 months ago

Working as expected with the right syntax :) workingDirectory

I presumed all lower case based on 1) my original example config and 2) all lower case used for other config multiword tags, i.e. waitbefore

Again, thanks for fix :)