So I have to write a .bat that checks if a .txt file is in use, if it is it just continually loops till the file is no longer being used, then it copies the file to another directory.

For the life of me I can't find ANY information on how to do this online, most people just have vbscripts and other stuff but this has to be done in via cmd in Win7 through a .bat.

I tried doing a Rename on the file to the same name, figuring it wouldnt rename the file if it was in use..apparently it does rename the file, and will even copy the file even if it is open and being changed.

Anyone have any suggestions on this?


Edit: To clarify, the actual .bat has to check if a .accdb file is in use and then loop back. I don't have Access on my computer though so I was trying to test it with a .txt. Maybe this is just an issue with .txt files being able to be overwritten while still in use by notepad?

Edit x2: It appears to work using MS word on fiances computer. it wont rename the file if it's in use.