WaitForFile

Download WaitForFile here (Europe) or here (USA) (~ 300kb).

This command line program waits until the file, specified as a parameter, can be opened exclusively. It can be used in .bat files if you want to process, such as copy, delete and so forth, a file that is currently opened by another program. WaitForFile will wait indefinitely until it can open the requested file.

Usage:

WaitForFile [r|w|rw] filename

The parameter r asks WaitForFile to try opening the file with exclusive read access.
The parameter w asks WaitForFile to try opening the file with exclusive write access.
The parameter rw asks WaitForFile to try opening the file with exclusive read/write access.
When WaitForFile exits, the file can be opened.