Processing a Terminal command

This is a rule I have setup with an AppleScript because I had no luck using any other methods. As you can tell from the screenshot below, I am trying to encode files as they come in, but I don't want all of them to encode at once. (Want it to work like a queue.. finish one file, then on to the next)

The problem with this, is that multiple Terminal windows are opened when multiple files match the criteria.
I need for Hazel to wait on Terminal to finish encoding one file, before moving on the to the next file.
I don't want to use the delay feature, because the encoding times can vary. Some can take 5 minutes, some 12 hours.
Can you please help?

The problem with this, is that multiple Terminal windows are opened when multiple files match the criteria.
I need for Hazel to wait on Terminal to finish encoding one file, before moving on the to the next file.
I don't want to use the delay feature, because the encoding times can vary. Some can take 5 minutes, some 12 hours.
Can you please help?