Color tag file when process is finished

I am trying to color tag a File as soon as handbrake CLI is finished converting it to a MKV-file. (Hazel will move file as soon as it is color-tagged. Problem is I cant set up Hazel to color-tag based om extension because then the file will get moved before the converting is done).

Have tried with this but cant get it to work. (Hazel need theFile as input)

tell application Finder
	set theFile to InputFile as alias
	if fileChanged(InputFile) then
		-- initialize the loop
		set Size_1 to size of (info for InputFile) -- get initial size
		delay 1 --wait 10 seconds, or whatever
		set Size_2 to size of (info for InputFile) -- get a newer size, perhaps different
		-- repeat until sizes match
		repeat while Size_2 ≠ Size_1 --if they don't equal, loop until they do
			set Size_1 to Size_2 -- new base size
			delay 1 -- wait ten seconds, or whatever
			set Size_2 to size of (info for InputFile) -- get a newer size
		end repeat --once the sizes match, the download is done
	end if
	tell application "Finder" to set label index of theFile to 5
end tell

I guess that knowing the code of the handler fileChanged(InputFile) would help to help you.

At this time I just say three things.

(1) the tell application “Finder” encapsulating the full code is useless.
(2) Not only it’s useless but it is a wrongdoer because we aren’t supposed to call a command belonging to an OSAX like info for (belonging to Standard Additions) in a tell block.
(3) info for is deprecated for years. It’s working today but it may stop to do some of these days.

According to that I made a bit of cleaning and got :

set theFile to InputFile as alias
if fileChanged(InputFile) then
	set size_1 to -1
	tell application "System Events"
		delay 1
		if size of InputFile = size_1 then exit repeat
		set size_1 to size of InputFile
	end tell
end if
tell application "Finder" to set label index of theFile to 5

At this time I don’t know what is the class of InputFile when we enter the code.
No problem if it’s an HFS path.
If it’s a POSIX path, the coercion to alias will fail whit this kind of error :
“Le fichier /WacomTablet_6.3.11w3.dmg est introuvable.” number -43 from “/WacomTablet_6.3.11w3.dmg”
The file /WacomTablet_6.3.11w3.dmg may really exists but AppleScript which is unable to do the coercion “understand wrongly” what is striking.

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) dimanche 31 janvier 2016 16:23:44