Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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.

[1] http://windows.microsoft.com/en-US/windows7/schedule-a-task

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? –  Odelya 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.