Page 1 of 1

Set File Icon?

Posted: Wed Jan 10, 2018 4:28 pm
by cmhjon
Hello,

Is there a way to set the icon of a file (a Microsoft Word file) for example? After checking the dictionary, there doesn't seem to be a way to do this?

Thank you so much,
Jon :)

Re: Set File Icon?

Posted: Wed Jan 10, 2018 4:36 pm
by Klaus
Hi Jon,

if you mean OUTSIDE of LC, then you might be able to do this in LC via AppleScript on a Mac
and VBScript on WIndows, but not with the build-in means of LC.


Best

Klaus

Re: Set File Icon?

Posted: Wed Jan 10, 2018 10:10 pm
by bogs
I think it can be done inside Lc though, depending on the situation. If your trying for a system wide reset, then I believe Klaus is correct.

Inside Lc, you have to come up with a character to represent the icon you want to use, then set it in the field so it will look like this (field on left and menu button above) -
Image

Re: Set File Icon?

Posted: Thu Jan 11, 2018 5:32 pm
by jacque
Most operating systems use the file extension to determine the icon and the default app that will open the file. Name your file with a ".doc" extension and it should work. Of course, if the file isn't actually a Word file, MS Word won't be able to read it.

Or did you mean you want to show the icon inside a LC stack?

Re: Set File Icon?

Posted: Thu Jan 11, 2018 7:24 pm
by cmhjon
Hi Jacque,

I am building an app that determines which version of an app a file was built with and then open said file with the appropriate app version (see viewtopic.php?f=7&t=30056).

I have all that working but because I have set several file types to open with my app, the icons of the files being opened with my app are changing to a generic file icon (which I am guessing is expected behavior) so I was trying to figure out a way to set the icon of said file back to the appropriate one.

Cheers,
Jon

Re: Set File Icon?

Posted: Fri Jan 12, 2018 6:58 pm
by jacque
So you're writing the file back to disk? There may be a shell call that will do it, since the user can assign a default app in the Get Info box in Finder, but I don't know what it might be. You may be able to find something with a Google search.

Re: Set File Icon?

Posted: Fri Jan 12, 2018 7:42 pm
by cmhjon
Other than changing the icon of the file, my app makes no changes to the file whatsoever.

Re: Set File Icon?

Posted: Sat Jan 13, 2018 2:30 am
by jacque
If you aren't saving the file then the icon shouldn't change. How are you opening it? Did you try opening for read-only?

Re: Set File Icon?

Posted: Wed Mar 07, 2018 7:40 pm
by cmhjon
Hi Jacque,

My apologies for the very slow response. After changing the 'Open With' setting (in the Get Info dialog box) for the file types I have designed my app to work with, I just double-click one of files (of course, my app also has the necessary CFBundleTypeExtension info within it). My app opens for a split second and then the appropriate app version opens the file.

Example: I double-click an Adobe InDesign file. My app opens, determines the correct version of InDesign the file was built with, and then opens the corresponding version of InDesign (and my app quits).

Thank you,
Jon :)

Re: Set File Icon?

Posted: Thu Mar 08, 2018 6:22 pm
by jacque
I'm guessing this is a Finder thing. If you change the "open with" app, the next time the Finder opens the file, Finder tries to reset the icon. It doesn't see an appropriate one because the file extension doesn't match the LC extension so it uses a generic one.

I don't see a way around that unless you can find a shell command to reset the icon. It's a system thing, not a LC thing. I'm speculating though.