问题描述
如果要添加新文件,我想监视我的文件夹.然后,如果添加了,我想执行一些文件.但是我不想使用第三方应用程序.
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.
这是我的文件夹; D:\ MonitoringFolder
This is my folder; D:\MonitoringFolder
因此,每小时处理一次的批处理文件都会检查其中的文件并将其写入txt.
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是->字符串1,字符串2,字符串3
Old.txt is --> string 1 , string 2, string 3
一个小时后,批处理文件将稍后检查并再次写入另一个txt.
After one hour, batch file will check it later and writes again into another txt.
dir /b "D:\MonitoringFolder" > new.txt
New.txt是->字符串1,字符串2,字符串3,字符串5
New.txt is --> string 1, string 2, string 3, string 5
然后它将比较new.txt和old.txt.因此,字符串5是最近添加的.它将提示一个窗口,并说字符串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.
推荐答案
由于您已经每小时都在转储输出,因此只需从提示符处执行以下命令即可:
Since you're already dumping the output every hour, just execute this command from the prompt:
fc /u old.txt new.txt
如果有的话,它将告诉您两个文件之间存在哪些差异.
It will tell you, if any, which differences exist between the two files.
这篇关于具有批处理文件的文件夹监视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!