Run bat file after save in NetBeans

713 Views Asked by At

I am using NetBeans 8.0.2 with PHP project. I have batch file called organizer.bat that configure to do some actions with the PHP source code.
Until now I run it manually after the code was changed.

I want that NetBeans will run my organizer.bat file automatically after I save a file in my project. How can I configure such behavior?

1

There are 1 best solutions below

0
On

One solution would be to have a batch file running in the background that periodically checks for new files in your project folder.

There's a lot of ways to do that. One way, for example, would be to output the directory files into a log file every 10 seconds. If the new log file matches the old log file, then the contents of the directory are the same and the batch file does not need to be run. The below commands will overwrite any existing log files.

:loop
cd C:\ProjectDirectory
xcopy logfile.log logfile2.log /f /y
dir > logfile.log

for %%I in (logfile.log) do set /a fs = %%~zI
for %%I in (logfile2.log) do set /a fs2 = %%~zI
if %fs%==%fs2% (echo "No changes in directory") else (echo "Changes in directory, run batch file.") 
timeout /t 10
goto loop