Automator file association

Hi,

I'm trying to associate an automator script that I wrote with a certain filetype.


What I'm trying to accomplish is that when a receive an email with a file with an extension .ggg, a certain program will be used to open the file.


To make a short story long, the file is actually an argument to a java program in the form of a jar file. The command line to run the program would be


java -jar program.jar $1


where $1 will be the name of the file attached to the email, for example myfile.ggg


As far as I can tell, there isn't a way to associate the .ggg type file with the program "java -jar program.jar", so I wrote a .sh script to handle this. The shell contains the command line mentioned above.


Then, to make things even more complicated, I wrote an automator script to move the file from the email to a temporary directory and then run the script on the file in the temporary directory. I named this automator script runprogram.app


I then selected a .ggg file, changed the application that it launches to runprogram.app, and pressed "change all" to associate all files of that type with the app.


I successfully did all of this on Leopard, and the process has survived upgrades to Snow Leopard and Lion.


Now I'm trying to do the same sort of thing on a brand new computer running Lion. Everything works fine until I press the "Change All" button. When I do that, it changes the name of the application to "Application Stub" (instead of runprogram.app), and messes everything up. (If I don't press Change All, only the particular file is associated with runprogram.app, not all files with the .ggg extension)


Thanks for your help.

MacBook Pro, Mac OS X (10.6.5)

Posted on Jul 3, 2012 12:35 PM

Reply
5 replies

Jul 3, 2012 2:09 PM in response to Geoff1234

Application Stub is the name of the executable file in the application bundle. Automator applications will accept pretty much any file type or extension dropped on them, but they don't have default settings to be associated with any particular file extension.


To customize things such as the application process name, bundle identifier, file types, etc, you are going to need to edit the Info.plist file inside the application bundle. Some keys to look at are CFBundleExecutable, CFBundleIdentifier, CFBundleName, and CFBundleDocumentTypes - see the Information Property List Key Reference.

Jul 3, 2012 7:22 PM in response to Geoff1234

Upon further investigation, this appears suspiciously like a bug. Here is what I learned.


I originally created the Automator app file in a previous version of OSX, probably Leopard. My automator app was named Runfile.app.


There is a folder inside the Runfile.app bundle in the folder Contents called MacOS, and within that folder is a file that is named Runfile. Also inside the Contents folder is a file named Info.plist, in which the key "Executable File" has the value "Runfile".


With the file in this format, I was able to open the Info screen for a file with the extension .ggg, and set "Open with" to Runfile.app. Pressing the button "Change All..." left the association of .ggg with Runfile.app unchanged, and every file with the extension .ggg would open with Runfile.app when it was clicked.


The situation is different with Lion. I edited the Automator app with Automator and made a small change. When I examined the new Runfile.app package, I discovered two differences. In the first place, the file inside Contents/MacOS was now named "Application Stub". Secondly, int the Info.plist file, the key "Executable File" has the value "Application Stub".


I opened the Info screen for my .ggg file, and again set "Open with" to Runfile.app. At this point, if I clicked on the speciflc .ggg file that I was working with, things functioned as expected. However, when I went back into the info screen and pressed "Change all...", the value under "Open with" was chaged from Runfile.app to "Application Stub", and an error message was generated when clicking on any .ggg file.


To solve the problem, I went into the Runfile.app package and renamed the file Contents/MacOS/Application Stub to Contents/MacOS/Runfile, and changed the value of key "Executable File" to "Runfile" in Info.plist. After doing that, I was able to go back into the Info screen for my .ggg file, set the value of "Open with" to Runfile, and press "Change all" without changing the value of "Open with". The program then ran as expected for every .ggg file.



Note that the new version of Runfile.app worked fine when applied manually to files with the extension .ggg, and worked fine when "Open with" was set to Runfile.app for specific .ggg files. Therefore, there is nothing intrinsically wrong with the Runfile.app bundle in the new format. However, the new format does not work when the "Change all" button is pressed. I would call this a bug. I don't know whether it is a bug with the Finder GUI (i.e., pressing Change all saves bad data into a configuration file), or with whatever software launches the app (misunderstanding what the data in the configuration file means.)

Jul 4, 2012 3:40 AM in response to red_menace

I'm not disagreeing with what you said. I got it to work by making changes along the lines that you suggested.


However, under Leopard I was able to associate the file type with the Automator app without having to go in and edit anything in the app bundle.


Therefore, I conclude that some change was made with Lion, and as far as associating apps with filetypes, that change made things more difficult. The change might have made other things easier, and therefore might deserve to be called a "feature" to some extent.


I don't see how somebody without a plist editor (I used Xcode) could have made the necessary changes at all. You might not call this a bug, but when I see something that used to work but doesn't work any more, I would say bug.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator file association

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.