Is there anyway to run scheduled task on directory at a certain time interval to see for file additions? The below code was found at https://mathematica.stackexchange.com/questions/15935/execute-code-when-file-is-modified/15938 and seems to not work anymore.
Begin["Kale`"];
fileName = "~/foo.txt";
lastModified = {};
updatedQ := With[{modificationDate = FileDate[fileName, "Modification"]},
If[lastModified == modificationDate, False, lastModified = modificationDate; True]];
task = CreateScheduledTask[If[updatedQ, Print["Changed"], ## &[]], {2, ∞}];
End[];
StartScheduledTask[Kale`task];
StopScheduledTask[Kale`task];