Progress Indicator for “Plain” Scripts.

Abstract: Given a scriptable AppleScript application (see below), create an easy way for plain (non-Studio) scripts to display a progress indicator.

Dependencies: (see below), and Mac OS X 10.2.

First, you’ll want to download this ZIP file. It contains the following files:


This is a simple application I made in AppleScript Studio. I’ve used it to ‘give’ a progress indicator to scripts that (I feel) don’t belong in AppleScript Studio.

“ Progress.scpt

This is what I want input on. Is there anything you would find useful, or is there anything I could do better?

“ Progress Demo.applescript

This is an example script. You may need to change it so it can find Progress.scpt. It should give you an idea of what this is supposed to do.

I’m not sure what else to say, but I know there’ll be questions. Feel free to ask. :slight_smile:

Thanks Bruce!

I got this working and its great… The only thing I can’t get is changing the icon.

I assume I’m suppossed to passing it something like

changeIcon to "HD:some folder:images:<filename>"

but its not working.

In it’s current state, the ‘changeIcon’ handler requires a POSIX path. (See also: TN2065.)

Try something like this:

changeIcon to POSIX path of ("HD:some folder:images:<filename>")

Also, note that I’ve included three icons inside You can use them like this:

changeIcon to "applet" -- default
changeIcon to "script"
changeIcon to "droplet"

Edit: Don’t use quoted form.

Hi Bruce,

Are there restirctions on the image that can be used? Size? Type? Dimensions? etc…

I tried linking to a few different image types (png, ico, icns) using POSIX paths and Apples Paths (whatever they are called) and I get this error each time.

Any thoughts what that might be?

Don’t use quoted form (see edited post above).

If you’d like to test images, use this script:

-- Change the path if you need to!
set Progress to load script alias (((path to scripts folder) as text) & "Lib:Progress.scpt")

tell Progress
	setTitle to "Image Test"
end tell

		choose file with prompt "Choose an image:" with showing package contents without invisibles
		tell Progress to changeIcon to (POSIX path of result)
	on error errorMsg number errorNum
		if errorNum is -128 then
			exit repeat
			display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
		end if
	end try
end repeat

tell Progress to quit

Bruce, thank you from the bottom of my heart for this! I have been looking for a simple progress indicator for some time and I’m sure I’m not alone.

Unfortunately, I am having trouble with this applet.

Here’s the relevant part of my script:

set Progress to load script alias (((path to scripts folder) as text) & "Progress.scpt")

set myFolder to POSIX path of (choose folder)
set myPOSIXFolder to quoted form of myFolder

tell Progress
	setTitle to "Progress"
	setStatusTop to "Executing Shell Script \"ls -Rip " & myPOSIXFolder & "\""

	set myListing to myFolder & "\r" & (do shell script "ls -Rip " & myPOSIXFolder)

end tell

I am getting an error “Progress got an error: connection is invalid”, followed by “Unknown Error: -609”.

I want to run this script on a folder that contains 10k+ items. I’ve tried it on smaller folders with success, but I can only run the script successfully once. I have to restart Script Editor in order to get it to run successfully again.

I appreciate any advice.

You shouldn’t tell Progress to do anything unrelated to it’s window.

Does it make any difference doing it like this?

tell Progress
	setTitle to "Progress"
	setStatusTop to "Executing Shell Script \"ls -Rip " & myPOSIXFolder & "\""
end tell

set myListing to myFolder & "\r" & (do shell script "ls -Rip " & myPOSIXFolder)

tell Progress to quit

As a side note, you could change “\r” to this:

-- In this context "return" means carriage return
set myListing to myFolder & return & (do shell script "ls -Rip " & myPOSIXFolder)

-- Or like this (also a carriage return)
set myListing to myFolder & (ASCII character 13) & (do shell script "ls -Rip " & myPOSIXFolder)

Thanks for the response. The problem doesn’t seem to lie with the “do shell script” call in the middle of the tell… end tell block. I’ve tried it the way you suggest without success. Wrapping the “do shell script” line in a “with timeout… end timeout” block helped once, but as before I am unable to run the script more than once successfully.

I should note that the demo script you include in the download also produces the error described earlier.

I think that the problem somehow lies with the “quit” subroutine. Commenting it out eliminates the error (although I have to quit the progress window via Activity Monitor).

Model: 400Mhz G4 AGP (Sawtooth)
AppleScript: 1.9.3
Browser: Safari 312.3.1
Operating System: Mac OS X (10.3.9)

This is the quit handler:

on quit
	quit application "Progress"
end quit

You’re saying that gives you an error?

Sorry, I should have been more clear.

I get the “connection is invalid” error in the Progress Demo.applescript you included. When I comment out the “quit” at the end of said script, I do not get the error but am left with the Progress Window on-screen (for obvious reasons).

The demo script is using the same handler. All it’s supposed to do is quit the Progress application. I don’t know what to tell you.

I’m stumped too. I have since “fixed” the problem by changing the “on quit…” handler in Progress.scpt to:

on quit
	tell application "Progress"
		end try
	end tell
end quit

Thanks again for a simple, much-needed tool!

How come you have to down load it? Why don’t you just post it?


I know this thread has been quiet for a while, but I have to add my thanks for this. It is awesome, and works exactly as it should! I will probably end up using it in every single script I write from now on. :smiley:

This is really cool. I have it ALMOST working. It does everything I want it to in the script except, everytime it launches, it asks me where the “Progress” app is.

I am attempting to use this in a way that I can send out scripts to others in our art department without having to copy support files to their drive. I would like the script app file to be self-contained. I was able to put the Progress app and the Progress.scpt in the script Package and then use Path To Me to load it.

How can I get it to automatically see the Progress app in there too? Is it possible to have an app in a file’s Package or is that illegal??

If this is not possible, I can add a step at the beginning to check that the app is on the person’s hard drive in a specific location and, if not, install it there. It would be cool if it could be all self-contained and still be a non-studio applescript…

set ScriptFile to ((path to me as text) & "Contents:Resources:Scripts:Progress.scpt") as alias
	set Progress to load script ScriptFile
	tell Progress
		setTitle to "Card Rasterization"
		setStatusTop to "Generating Quark EPS."
	end tell

Model: Mac G5 OS 10.3.9
Operating System: Mac OS X (10.3.9)

EDIT: I fixed my problem. See below.

With regards to it requesting the location of the, I was surprised to see that it did not do that on my machine. It might on first install on another machine, I don’t know.

I used “path to resource” to tell it where the .scpt file was, so maybe that triggered Launch Services to pick up the .app in there too.

LOL - never mind.

error -10660 means the app that is being requested is in the Trash.

I had copied to the bundle and then deleted the original but forgot to empty the Trash.

Everything works perfectly now. The “path to resource” works great for the .scpt in the bundle, as the command “path to resource” defaults to the Resource folder of the bundle of the currently running script.

Thanks for this feature!!! I plan to just make a bundle template with the scpt and already in it and that way it is completely transparent to distribute scripts that use the progress bar.

Hmmm, is “path to resource” a new Tiger feature. I am in Panther and it is not working…


That’s in the Release Notes.

I think, though, that the following is equivalent:

POSIX path of (path to me as Unicode text) & "Contents/Resources/"

EDIT: fixed mismatching parentheses, removed leading slash before “Contents”.

I got my template made. It is an Application Bundle that contains the script template, which has comments for remembering what the calls to the Progress.scpt handlers are, a single line of code that sets the variable “Progress” to the script object “Progress.scpt” which is the result of the “load script” command, and the script “Progress.scpt” and the app “” as items in the /Contents/Resources directory of the template.

So all I have to do is take an existing script, copy and paste it into the template, Save As… a different name, and then add in the calls to the handlers in Progress.scpt within a “tell Progress” block.

Finder automatically knows about and you don’t have to do anything special for Progress.scpt to launch it. I presume that has its “UIElement” bit set so that it does not appear in the Dock or in the Menu Bar when it is running.

There are no extra files to install or include in the .dmg when you distribute your script, no instructions needed on where to install extra things, no reliance on third-party daemons or osaxen, and nothing to launch or quit except the call to Progress.scpt’s “quit” handler at the end.

I see this as a technique of getting a lot of “AppleScript Studio-only” functionality into a regular script. It’s very clever.