CarlosNZ Posted January 29, 2013 Posted January 29, 2013 Hey all, I wonder if anyone knows a way to get the icon of a specific file on the local system. Shell script, applescript, whatever, I'm interested. From my googling, I've found plenty of explanations of how to get the icon of an app (pretty obvious really — it's in the bundle), or to specify an icon for various tasks, but I'd really like to be able to retrieve whatever icon the Finder displays for any file to use in my workflow script. Even a generic one (jpg, pdf, etc.) would do. BTW, if I just refer to the file itself in the "icon" field of Alfred's XML, it does sort of work, but it shows a really shrunk-down "quick-look" icon, not a proper icon, and it's really fugly. And folders don't have anything. If I can't find something, I'm just going to embed a limited set of generic file-type icons and have them show up for general file types. This will probably be quite tedious, so it'd be great to know if there's a better way before I head down that path. Thanks in advance for any suggestions. C
Andrew Posted January 29, 2013 Posted January 29, 2013 Alfred actually makes this quite easy for you, you can add a type parameter to the <icon> part of the XML to show file types e.g. <icon type="filetype">public.jpeg</icon> ...to show the icon for the UTI. If you want the actual icon for the file, you can use e.g. <icon type="fileicon">~/Desktop</icon> ...to get the actual icon used for the given path. CarlosNZ, phyllisstein and franzheidl 3
CarlosNZ Posted January 29, 2013 Author Posted January 29, 2013 Brilliant! I knew there had to be a simple way. Thanks Andrew.
schleifer Posted January 30, 2013 Posted January 30, 2013 Alfred actually makes this quite easy for you, you can add a type parameter to the <icon> part of the XML to show file types e.g. Is there a parameter that works for bundle ids? So we could get an icon from an application if the path is unknown?
ClintonStrong Posted January 30, 2013 Posted January 30, 2013 Is there a parameter that works for bundle ids? So we could get an icon from an application if the path is unknown? I think you can just give it the path of the application. Of course, it wouldn't work if the application was moved or renamed. Not sure if there's a way around that.
schleifer Posted February 1, 2013 Posted February 1, 2013 I think you can just give it the path of the application. Of course, it wouldn't work if the application was moved or renamed. Not sure if there's a way around that. I'm thinking specifically about preparing workflows for distribution. For non-Apple software, they might be installed in /Applications or ~/Applications (or anywhere, really). Being able to use something like <icon type="bundleicon">com.example.Foo</icon> would be useful in that case.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now