VisualHub folder actions

I’m trying to make a folder action that will watch a folder i download to, label it then if the file format is a video it would convert to a mp4 then copy it to another folder. the trouble I’m having is i want to delete the original one after it is converted.

on adding folder items to this_folder after receiving these_items
	set fileColorList to {oranges:{"mkv", "avi", "wmv", "mov"}, reds:{"rar", "sit", "dat", "bz2", "tbz", "hqx", "mpkg", "iso", "bin", "ppt", "dmg", "sit", "rar", "gz", "zip", "tar"}, yellows:{"torrent", "txt", "rtf", "scpt", "htm", "html", "xls", "xml", "plist", "pl"}, greens:{"mp4"}, blues:{"mp3", "m4a", "wma", "wav", "aiff"}, purples:{"gif", "png", "jpeg", "bmp", "tiff", "raw", "pgf"}, greys:{"dmg", "bin", "iso"}}
	
	tell application "Finder"
		
		repeat with myFile in these_items
			--display dialog myFile as string
			if the name extension of myFile is in oranges of fileColorList then
				set label index of myFile to 1
			else if the name extension of myFile is in reds of fileColorList then
				set label index of myFile to 2
			else if the name extension of myFile is in yellows of fileColorList then
				set label index of myFile to 3
			else if the name extension of myFile is in blues of fileColorList then
				set label index of myFile to 4
			else if the name extension of myFile is in purples of fileColorList then
				set label index of myFile to 5
			else if the name extension of myFile is in greens of fileColorList then
				set label index of myFile to 6
			else if the name extension of myFile is in greys of fileColorList then
				set label index of myFile to 7
			end if
		end repeat
	end tell
	delay 30
	set input_list to oranges of fileColorList
	
	tell application "VisualHub" to set VisualHub to load script (scripts path of main bundle & "/automation.scpt" as POSIX file)
	tell VisualHub
		repeat while item 1 of CheckStatus() is not equal to 1
			delay 30
		end repeat
		
		ClearAll()
		
		AddFiles(input_list)
		
		LoadSettings("Mac Home Server:Users:tomwynne:Desktop:settings.vhub")
		
		SetSaveLocation("Media:Movies")
		
		delay 15
		
	end tell
end adding folder items to

I don’t know anything about Visual Hub, but a folder action triggers whenever a new file appears in the active folder. That means that the FA will interpret a name change (which includes the extension) as a “new” file. Your script should move the file to its final (or a temp) folder, convert it there, and then delete the original. If you intend to dump a bunch of files into this folder and the process of converting one takes very long, you’ll miss some of them. For chores like this, I’d be inclined to use the FA to color label your files (I assume VH pays attention to that), then use a separate script to batch process them.

Well in visualhub the output folder is set different then the original folder so it dose go to another folder. The labels don’t matter there just a point of reference when browsing the directory. The orange label ones get converted in this case. It would be cool to change the label once the conversion is done then after a short time delete
it but i will just settle on deleting them when done

set F to alias ((path to desktop folder as text) & "someFile.txt")
tell application "Finder" to move F to trash