Compressing Applescript App loses Paths

Hello,

I created an Applescript Application that within the Resources is using the “SKProgressBar”. Everything works fine but when I compress the Application to attach in an e-mail, the recipient unzips it and when they try to use the app it is now asking for the location of the “SKProgressBar.app”.

I’ve provided below the script where I think I put in the correct information to Applescript to always link the SKProgressBar app to the Resources folder

on open adisk
	set Remove_DS_Store to "cd " & quoted form of (POSIX path of adisk) & " ; find . -name '.DS_Store' -type f -delete"
	do shell script Remove_DS_Store
	set MD5 to "cd " & quoted form of (POSIX path of adisk) & " ; find * -type f -exec md5 -r {} \\; | sed 's/ /  /' > *CHECKSUM.md5"
	set iconPath to ((path to me) as text) & "Contents:Resources:droplet.icns"
	set theApp to "SKProgressBar"
	set pathToSKProgressBar to ((path to me) as text) & "Contents:Resources:SKProgressBar.app"
	
	tell application "SKProgressBar"
		activate
		set floating to false --> default is true
		set position to {500, 550} --> default is {1000, 750}, origin point is bottom left
		set width to 450.0 --> default is 500.0
		set title to "CreateMD5"
		set header to "Processing..."
		set header alignment to center
		set footer to "" --> default is empty string
		set footer alignment to center -->  default is left
		-- image path can be HFS or POSIX path, default is missing value (no image)
		set image path to iconPath
		set show window to true --> default is false
		tell progress bar
			set indeterminate to true --> default is true
			start animation
			do shell script MD5
			stop animation
		end tell
		quit
	end tell
	activate
	beep
	display dialog "        Checksum Complete!" with icon 1 buttons {"Close", "Open Directory"} cancel button 1 default button 2
	tell application "Finder"
		open adisk
	end tell
end open

If anyone can point out the issue and how to resolve this that would be a HUGE help! Thanks in advance!

They’ll need SKProgressBar as well.

You’ll have to provide a link, or make SKProgressBar download if it isn’t on the machine. (your script fails to run it.)

Maybe StefanK lets you put SKProgressBar in the Contents:Resources folder of your app, if your app is free and you ask very nicely. :slight_smile:

Easiest solution is just provide the SKProgressBar app to them. This app is just used for personal use and really for me to start learning more about Applescripts and such. If there is a way to tell the Applescript to “Only” look for the SKPorgressBar app within the Resources folder, awesome! If not, there is still a work around solution and I will try new things.

BTW, Thanks StefanK! :slight_smile:

Hi.

You could try addressing the application by its path. You’d have to use ‘using terms from’ to get the script to compile:

on open adisk
	-- Initial stuff here.
	
	set pathToSKProgressBar to (path to me as text) & "Contents:Resources:SKProgressBar.app"
	
	using terms from application "SKProgressBar"
		tell application pathToSKProgressBar
			
			-- SKProgressBar stuff.
			
		end tell
	end using terms from
	
	-- etc.
end open

A couple of points about your script:

  1. A droplet’s ‘open’ handler receives a list of dropped items, so that’s what the value of ‘adisk’ is. You’ve assumed only one item will be dropped. Ideally, you should code for the possibility of more so that the script will react appropriately. What’s appropriate, of course, is your decision. :slight_smile:
  2. You’ve also assumed that the item will be a disk.
  3. ‘path to’ has its own ‘as’ parameter which can tell it to return text directly. This is slightly more efficient than having a later coercion:
((path to me) as text) --> 'path to' returns an alias, AppleScript coerces the alias to text.

(path to me as text) --> 'path to' returns the text itself.

I trust you’ll credit Stefan and the app somewhere in the comments or the “Read me” file. :slight_smile:

Thank you very much, Nigel!

I will be sure to make the adjustments you mentioned below and also test out having the app run from the SKProgressBar from within the app :).

What would the parameters be for opening multiple files (and still having the MD5’s go to the files respective locations)?

I will make sure to put info within the Script. The Read Me file I created for myself (in case I forget something) has in a thanks to StefanK as well :).

Again, thanks StefanK! Also thanks again to Nigel and McUsrII!