Another Wait question

I know there’s a lot of questions about getting the script to wait…yes, this is another. I need my script to wait until a shell command finishes to move on. The only thing is that my shell script doesn’t return anything when it’s done. And I can’t use a “with timeout of” because it’s completely dependent on the size of the file (it could take 3 seconds or 15 hours). Same thing for using a delay statement. Is there any way I can do this?

Hi,

with timeout doesn’t work anyway with shell scripts.
It works only with applications, which receive and respond to Apple Events.

Normally the script waits and continues after the shell script has finished.
Does your shell script behave different?

It is definitely not acting this way. I think I read that if I have it write a log file as it goes that it makes it a background process and then will move forward in the script? Is this true? I don’t 100% have to write a log file, but I would certainly prefer to so that I can keep tabs on things. My shell (I know you’ve seen my command many times in the past week:) ):


do shell script "/Applications/ffmpegx.app/Contents/Resources/ffmpeg -i " & quoted form of POSIX path of this_item & " -vcodec mpeg4 -b 2000 -s 640x480 -y -acodec aac -ab 448 -ar 48000 -vol 1024 -comment \"Made Possible by the Vermont Media Exchange\" -title " & quoted form of Nm & " -copyright 2007 -f mp4 " & destinationFile & "&>~/Library/Logs/ffmpeg_transcode/" & quoted form of Nm & ".log.txt "

I just tried your script in the trace mode of Script Debugger (step by step)
It is definitely waiting. The next line after the shell script will be executed after the conversion has finished

This is in the form of a droplet. So when I drop multiple files onto it, it must be running the app twice? So there’s no way I can get it to only run one instance?

I tried this code, saved it as an application and dropped two mpg files on it.
Both files has been processed consecutively and the voice message has come just after each conversion

on open these_items
	repeat with this_item in these_items
		set Nm to name of (info for this_item)
		set destinationFile to POSIX path of this_item & ".mp4"
		do shell script "/Applications/ffmpegx.app/Contents/Resources/ffmpeg -i " & quoted form of POSIX path of this_item & " -vcodec mpeg4 -b 2000 -s 640x480 -y -acodec aac -ab 448 -ar 48000 -vol 1024 -comment \"Made Possible by the Vermont Media Exchange\" -title " & quoted form of Nm & " -copyright 2007 -f mp4 " & quoted form of destinationFile & "&>~/Desktop/" & quoted form of Nm & ".log.txt "
		say (Nm as string) & space & "finished"
	end repeat
end open