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

2 Answers

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

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
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.