I’d like to be able to determine if a directory such as a ‘.app’ is considered to be a package or bundle from Finder’s point of view on the command line. I don’t think this would be difficult to do with a small shell program, but I’d rather not re-invent the wheel if I don’t have to.
Share
Update:
On all systems with Spotlight, using
mdlsyou can detect bundles looking at the kMDItemContentTypeTree property. E.g.:produces the following output for me
Whenever you see
com.apple.packagethere, it is supposed to be displayed as a package by Finder. Of course, everything with ‘bundle’ in the name implies that already but not all packages are bundles (bundles are a specific subset of packages that have a well defined directory structure).Old Answer:
You can get a list of all registered file type extensions, using this command (OS X prior to Leopard):
or for Leopard and later:
Every file extension there has flags. If the package flag is set, this is a package.
E.g.
Compare this to a file that is no bundle
The only way to really get all bundles is by looking up in the LaunchService database (the one we dumped above). If you just go by whether it has a plist or not or whether the bundle bit is set or not, you might catch some or even many bundles, but you can’t catch all of them. This is the database Finder uses to determine
and some more stuff.
[EDIT: Added path for Leopard, thanks to Hagelin for the update]