Sign in to follow this  
Followers 0

Wait for file to finish writing

2 posts in this topic

First I'd like to say how much I love AutoIt, this is as close to programming as my brain will allow. I'm an artist so my brain doesn't work that way. Now simple scripting is all I need to know.

I use MediaPortal to record television and I'm trying to automate the commercial detection and cutting of my files. I've been using the script below to wait until commercials are being processed by Comskip. When the file is finished Comskip creates a batch file which, when run, cuts the detected commercials out of the video file. The script then moves it into my video directory and cleans up.

What I'd like to add to this script is for it to detect when a video file is finished recording so it can then run the file using Comskip. MediaPortal doesn't have a separate process for its recording, so I'm not able to look for that process and wait for it to finish. Is there anyway to make the script smart enough to know when the file is no longer being used by MediaPortal? It doesn't work otherwise.

;Run and delete Comskip batch files

While 1

;Wait for Comskip to start and finish

ProcessWait ( "comskip.exe" )
ProcessWaitClose ( "comskip.exe" )

;Search for and run batch file

    $search = FileFindFirstFile("*.*")

    If $search = -1 Then

    While 1
                $file = FileFindNextFile($search)
                If @error Then ExitLoop
                If StringRight ($file,3) = "bat" then run($file)


;Wait for DvrCut, then move files and cleanup

ProcessWait ( "DvrCut.exe" )
ProcessWaitClose ( "DvrCut.exe" )
FileMove("C:\My Recordings\*.dvr-ms", "C:\My Videos\Recordings\*.dvr-ms")
FileDelete ( "C:\My Recordings\*.bat" )
FileDelete ( "C:\My Recordings\*.txt" )
FileDelete ( "C:\My Recordings\*.log" )


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0