Quicktime Save As and Import to iTunes Script

Hey all,
I’m not great with applescript and tried to do this with automator but couldn’t so I was hoping someone could help me out…I want to have a script that:

Watches a Movies folder for new .avi files added (the movie files themselves will most likely be in a folder inside the Movies folder…so it would have to be able to watch a level down).

When a new .avi file is added, it opens the file in Quicktime and Saves As a “reference” file.

Then it imports that reference file into iTunes.

That’s it…
The other thing is that I don’t know if applescript can “watch” a folder for new files (and disregards old ones in the folder)…if it can then great! if not, then I’d have to add a step: It watches for new .avi files in a temp folder, opens in quicktime and makes a reference file, then imports the reference into iTunes, THEN it moves the OLD .avi file (not the reference) to the Movies folder, and hopefully along with the folder the .avi file was in.

If anyone can help me figure this out that would be AMAZING. Thanks all, Matt

So I’ve found and edited an applescript that, when saved as an application, acts as a droplet that completes the second part of the script I want to create. This is what I have:

on open ml_movie
set my_location to (path to desktop) as text
tell application “QuickTime Player”
close every movie
open ml_movie
set movie_name to name of movie 1
set save_location to my_location & movie_name & “.mov”
save movie 1 in save_location
end tell
end open

So this just creates the reference file on the desktop. One problem with this is that it still has the .avi extension. For example if I have a movie called Movie.avi and I use this droplet on it, then the resulting reference file is Movie.avi.mov. I want the reference file to just be Movie.mov.

Also this script is obviously not complete. I can probably figure out how to import the reference file into iTunes…actually just did:

set movie_reference to save_location
tell application "iTunes"
	launch
	add movie_reference to playlist "Library" of source "Library"
end tell

but have no idea how to have applescript “watch” a folder for new files so that when a new movie is download, it acts on the .avi file, makes a reference, and then adds the reference to iTunes.

Anyway, just felt like telling ppl my progress and if anyone has any suggestions or can help me out. Thanks, Matt