I want to monitor my folder if new file added or not. Then If added I would like to execute some files. But I don't want to use third party app.
I have some ideas but I don't know how to do that.
This is my folder; D:\MonitoringFolder
So every hour batch file will check the files inside of it and writes them into a txt.
dir /b "D:\MonitoringFolder" > old.txt
Old.txt is --> string 1 , string 2, string 3
After one hour, batch file will check it later and writes again into another txt.
dir /b "D:\MonitoringFolder" > new.txt
New.txt is --> string 1, string 2, string 3, string 5
Then it will compare new.txt and old.txt. So string 5 added recently. It will prompt a window and says "String 5" added!. Or new file added (removed).
I want to do that If someone could show me a way to do this I would appreciate that.
Script MONITOR.cmd scheduled to run every now and then:
Script INSERTED.cmd will create new window prompting for action on appearing of a new file:
Script DELETED.cmd will create new window prompting for action on disappearing of an old file:
Subfolders are monitored, too. It worked for me even with spaces and accented characters in filename.
Maybe you're going to write batch scripts (for scanning folder and compare results) and schedule them with a scheduler like cron (Linux) or windows task scheduler every hours for e periodical checking. Some documents here : http://support.microsoft.com/kb/308569 , http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800
Since you're already dumping the output every hour, just execute this command from the prompt:
It will tell you, if any, which differences exist between the two files.