Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder on my windows 7 pc, that once a file was copied successful to my folder - I would like to invoke ant script/call java code that will accept the file name and location.

How can I do it?

share|improve this question
up vote 1 down vote accepted

In Windows 7, there is a built-in Task Scheduler [1]. You could write a Java class (or Ant script) that would execute every 5 minutes, for example, check the files on that folder and perform an action on any file in it.

Of course, this implies a certain delay in processing the file; and if you reduce the delay, then you will likely have to control concurrent access if two instances of the job end up overlapping, but it could be a start.


Also see: Run script on Windows every n minutes

share|improve this answer
What is the best way to know that the file copy was finished? maybe it's in the middle? – Dejel Feb 15 '11 at 15:37
Some quick searches indicate there is no definitive solution to this. One option is to observe the file's last modification date. For example, files unchanged in the last 3 minutes are likely to be finished. Another option is to detect that the file is in transit (example: if there is a file a.txt and a file a.txt.part, it means it's still in progress. Maybe only the .part file exists, in this case it will be renamed when finished and you can just ignore it for now). This would depend on who puts the file on your folder and how (nfs share? samba? simple copy on the same machine?). – st.never Feb 15 '11 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .