saving scripting additions in a bundled script

I can’t get a scripting addition to stay bundled with a saved script, either as a script bundle or an application bundle. Inside Resources, there is a Script folder. I make a new folder Scripting Additions (with the space) there, and then paste an addition there (in this case Date Format.osax). This can be done outside the script editor, using Show Package Contents, or inside the editor using the Bundle Contents icon in the upper right. From within the script editor, I save the script as either an application bundle or script bundle. Then exit the script editor, do a Show Package Contents, and the Scripting Additions folder is gone. If saved as a bundled applet, so I can run it, it doesn’t see the Date Format.osax and so fails (I temporarily remove Date Format.osax from the ScriptingAdditions folder in /System/Library for this test). What am I doing wrong? BTW, this is a “stay open” script, as it has an idle routine. Please help.


do you really need this scripting addition?
This might do the same

set TimeStamp to do shell script "date -n +%Y-%m-%d_%H-%M-%S"
--> 2007-10-23_hh-mm-ss

The Scripting Additions folder should be inside the Resources folder, not the Scripts folder.

Other options would include using PHP (or a similar language) with do shell script [Edit: example], or the (possibly more complicated) appleMods Date library.

Right. Perhaps my note was not clear. I put the Scripting Additions folder in Resources, the same location as the Scripts folder. But it disappears.

The date command in the shell doesn’t work because it will only format the current date and time, not any arbitrary one. Yes, there are ways to do it in AS, but the date format.osax addition is very easy to use and fast. The older version of it did not work with OSX 10.4 (or 3) but when I wrote them they made a new version that works fine. You can download it for free from here

But I would still like to be able to bundle Scripting Additions with a script. Why doesn’t it work?

I just tried it (on a PPC 10.4.10 system) and it works fine.
I did these things:
¢ install the OSAX in Library/ScriptingAdditions to be able to compile the script
¢ create a script with the format date command, I used this code:

set theDate to format date (current date) with format "%m, %d %Y"
display dialog theDate

¢ save it as application bundle
¢ create a folder Scripting Additions in Contents/Resources of the bundle and save the OSAX also in there
¢ copy the script to another machine (without the OSAX installed) and run it

Works fine on my Intel-based 10.4.10 system too.

Are you having this problem when normally saving, or when using Save As?

You got it! I was doing a Save As to make sure that it was saved without a Startup Screen and as Stay Open. If you do that, the folder disappears. But if you do a save as first, just to make sure the right options are set, and then in Script Editor use the bundle icon to drag in the scripting additions folder, and then do a normal save, it works. Or, as Stefan K notes above, if you put in the scripting additions folder AFTER saving the application bundle, using the Package Contents approach, it is OK too. But DO NOT drag the application back onto the script editor to work on it again, as that will make the folder disappear!

I am going into detail here just to warn other readers about how NOT to do it!

Thanks, Bruce, for mentioning the Save As possibility.