Use Hazel

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Use Hazel Fri Sep 26, 2008 1:06 pm • by grovberg
I'm wondering if anyone has any bright ideas here. The short version is that I'm wondering if there's any way to Hazel do anything to a file that's "busy" but I suspect there isn't.

The long version is that I'm using Hazel as the basis for an automated encoding system that allows instructors at my university to make recordings and have them automatically encoded and uploaded to our online video delivery system. The instructor remotely activates an AppleScript that starts recording (via Vidi if you're interested) and another AppleScript that stops recording. Hazel watches the recording folder and looks for files that haven't been modified in the last ten minutes and moves it to the encoding folder where all manner of other things happen via Hazel.

The problem I'm running into is that from time to time, an instructor will turn the recorder on and then walk away with it still running so that it fills up the hard drive entirely. So I'd like to limit the recording length. Any suggestions on how I might do that? I tried creating a rule that would activate the "Stop Recording" AppleScript once the file got to a certain size, but log reports that the file is busy, so it's being skipped.

So am I correct in thinking that I won't be able to use Hazel for this? Any suggestions (Hazel or otherwise) are appreciated.
grovberg
 
Posts: 17
Joined: Thu Nov 30, 2006 3:44 pm

Re: Use Hazel Fri Sep 26, 2008 2:54 pm • by Mr_Noodle
Unfortunately, Hazel won't touch the file if it's busy. My suggestion would be to rig something in the AppleScript. Does the script have to exit or can it stay running and wait a certain period of time?

The other thing you can do is have the AppleScript write a different fake file, based on the filename of the video file being recorded (use a special extension or something). You can then have Hazel look for this file and if it was added more than some time ago, run another AppleScript that will stop recording (it can figure out which file since the fake file has a similar name). It's not based on size but if you are recording at the same bitrate every time, then you can do a correlation between the time and size.

Let me know if the above works or if you need more ideas.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Use Hazel Sun Sep 28, 2008 2:13 pm • by grovberg
The other thing you can do is have the AppleScript write a different fake file, based on the filename of the video file being recorded (use a special extension or something).


This is a brilliant idea and way better than trying to leave an AppleScript running for three hours! I'll give this a shot this afternoon.

Can I also take a second and just say how awesome it is that we can come here and talk to you directly? It sure is a big difference from trying to get an answer out of Adobe or something. :D

Thanks a million.
grovberg
 
Posts: 17
Joined: Thu Nov 30, 2006 3:44 pm

Re: Use Hazel Mon Sep 29, 2008 5:34 pm • by Mr_Noodle
Well, I'd like to think I'm a little more agile than Adobe. :P
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Use Hazel Mon Sep 29, 2008 8:32 pm • by grovberg
Mr_Noodle wrote:Well, I'd like to think I'm a little more agile than Adobe. :P


No seriously. It's taken me over a month and four different reps just to find out how much a piece of software costs and where we could buy it from them. It's truly amazing. But even among indie developers, you really go above and beyond and it really means a lot.

Anyway, I thought I'd come here and document what I did in case it might help someone else. I didn't need to do anything fancy with the filename. The AppleScript that starts recording now creates a file in a different folder called RecordingOn.rec (do shell script "touch RecordingOn.rec") along with starting the recorder, and the AppleScript that stops recording will delete the file. I've got Hazel looking for any file with the name RecordingOn.rec whose date modified is more than 3 hours. If it finds it, it runs the AppleScript that stops recording. Success!

This method is also great because it doesn't mark the file as having been filtered, so the three hour recording still gets processed as usual.

Also, I had trouble at first because I used Name instead of Full Name when I was trying to match the filename, so watch out for that.

Thanks again for the great idea.
grovberg
 
Posts: 17
Joined: Thu Nov 30, 2006 3:44 pm


Return to Open Discussion