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 need to periodically move some tv records, however it is possible that one of them is still recorded during moving. now i need a batch utility that can detect if a file is already completely written or there is still data written into it. if there is still data written to it, the moving of this file shall be skipped. the problem is, that currently e.g. move command simply moves what's already there, the recording software (windows media center) doesn't seem to really lock the file to prevent such things. so, how to move only finished recordings?

share|improve this question
up vote 0 down vote accepted

If Media Center will not lock it, I guess it's hard to know. Slightly different approach, but it might fit your purposes, you can use robocopy to move files that are older that 1 day.

robocopy [src] [dest] /mov /MINAGE:1
share|improve this answer
    
Thank you, it works using robocopy, robocopy seems to do the moving different than e.g. xcopy - xcopy moved the file in use by windows media center, robocopy copies it partially but can't delete it, therefore recording will continue and on the next robocopy run the complete recording will replace the partially copied one as it's newer :-) – stefan.at.wpf Mar 22 '12 at 13:44
    
oh, and it works without the minage stuff, just let robocopy try moving ever recording. – stefan.at.wpf Mar 22 '12 at 13:45

The other way to do this is to check if anything is being recorded and only move files when nothing is. This can be done very easily by determining whether or not ehrec.exe is running:

tasklist /FI "IMAGENAME eq ehrec.exe" 2>NUL | find /I /N "ehrec.exe">NUL
if "%ERRORLEVEL%"=="0" echo Something being recorded
share|improve this answer

You must log in to answer this question.

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