0

I need to associate particular folders with my application in order to launch the app by a double-click on the folder, as if it were a bundle folder. Those folders should even have their own icon.

I've been able to achieve this by providing the folder with an extension and setting up the document type part of the application's Info.plist file.

Unfortunately, I don't want to add an extension to the folder, I want to associate regular folders with my application. To be precise I want to associate every folder which contains a subfolder called "Subfolder" (for example).

Is there a way to achieve this?

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
Andrea3000
  • 1,018
  • 1
  • 11
  • 26
  • 1
    This seems like it would provide a confusing experience for the user. I don't think it would be expected to double-click a regular folder in Finder and have it launch an external application. – sbooth Mar 04 '12 at 17:43
  • @sbooth: That can be true but if the folder has a custom icon which avoids this confusion then I think that it can be done. Don't you think? – Andrea3000 Mar 04 '12 at 18:11
  • No. A folder is a folder and treating it otherwise would break the Mac user experience. – Rob Keniger Mar 05 '12 at 03:27

1 Answers1

1

You shouldn’t do that (from the user experience point of view) and you can’t do that (from the technical point of view, unless you consider patching the Finder an option).

What are you actually trying to achieve? Would creating a package/bundle and hiding the path extension work? You can do that through NSFileManager:

NSString *path = …;
NSDictionary *attributes = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFileExtensionHidden];
NSError *error = nil;
[[NSFileManager defaultManager] setAttributes:attributes ofItemAtPath:path error:&error];

To associate an existing folder with your app you could rename the folder to have your package file type path extension.

gcbrueckmann
  • 2,413
  • 18
  • 10
  • Thank you for the answer. Unfortunately I can't adopt the solution you suggest because I need to perform folder-application association even on read only disks. What I'm trying to achieve is this: my application handle a structure of files placed in a standardized folders' structure. I want to double click on the main folder which contains the whole files and folders structure and launch the app. – Andrea3000 Mar 04 '12 at 19:24
  • You can do that without giving the folder a file extension by setting the folder's bundle bit, which will make the Finder see the folder as a single file. iPhoto does this with its iPhoto Library folder. I explain how to set the bundle bit in [my answer to this question](http://stackoverflow.com/a/2010698/50122). – Rob Keniger Mar 05 '12 at 03:29
  • But that way the package still won’t open in your app, or am I mistaken? Also, this method won’t work on read-only volumes either. – gcbrueckmann Mar 05 '12 at 11:38
  • @RobKeniger: Thank you for your help but I'm looking for a solution that doesn't involve the modification of the folder. – Andrea3000 Mar 05 '12 at 21:52