Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applying custom icons to all files of a type

I used to use ResEdit back int he day - and have used various tools on Mac and Windows to change icons. BUt I am stuggling with a default custom icon option for Mac OS X.


I have a set of farily simply icons for use with a number of file types that I use a lot - csv, psl, pti, tp3, xml, cfr, and others and I would like to always have newly created files get the custom icon.


Ideally this would be based on the extension - and they are not all from the same app.


I am not afraid to use the terminal or edit package contents. Although some of them are windows apps - and I already have a custom set in the virtual machine.


Some of the solutions I have seen out there such as Candy Bar seem to be only for application and folder settings.


In a couple cases - such as the .cfr and .pti - the apps do not have an open method where you can double click on the file and have it open - so I woudl be okay with something like reprogramming TextEdit to have the necessary icons and plist updates. Although when I tried to edit the plist file in TextEdit - all I did was render TextEdit unusable.


any help in the right direction will be appreaciated - I find it very helpful when I create 30 to 40 files ( a group of 5 differnet file types for each option ) to have icons that help me determine which ones I need to run a macro against - and which to send the customer - and which to upload to the vendor - etc.


Also missing the colorful icons in the sidebar and iTunes - as well an Unsanity Haxies - guess what audio feedback does make me more productive or at the very least more certain that the system is behaving as I expect.

MacBook Pro 2011 17, Mac OS X (10.7.2), iPhone 4s 64GB

Posted on Feb 25, 2012 8:14 PM

Reply
19 replies

Feb 25, 2012 9:30 PM in response to Matt Wolanski

You should be able to select one of the files. Then, "Get Info" (command-i) and paste the icon. Then "In the Open With" tab, choose the app and click "Change All"?


EDIT: There is a third party software that changes the Sidebar icons back to color. Search the forums, I don't remember off hand which it is. The downside is that you need to redo it after every update. Got it...

http://www.macupdate.com/app/mac/40989/colorfulsidebar

Feb 26, 2012 7:08 AM in response to macjack

Change all only affects the application that opens all the files of that type - it does not reapply the custom icon to all the files - that is where the need to either trackdown the app that contains the icon and modifty that or set a separate app with the necessary icons.


I have seen some sidebar and itunes colored icon and yes it is annoying that every update from apple undoes that "fix"

Feb 26, 2012 8:06 AM in response to Matt Wolanski

I think that you are looking at a lot of work here. There are some default icons that the system uses, but typically a document icon is containied in the default application, and the various document icons are defined in the application's Info.plist for each particular type of document (a non-standard application bundle would just get generic document icons). None of these use the creation date to vary the icon, so you would probably need to group your documents together like everyone else does - into folders.

Feb 26, 2012 8:18 AM in response to macjack

I did come across that - but get the following:


with sudo

sudo: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ LaunchServices.framework/Versions/A/Support/lsregister: command not found


without sudo

/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/L aunchServices.framework/Versions/A/Support/lsregister: No such file or directory


Also editing the info plist of text edit is tricky - it is locked - then wants to edit a duplciate - and you cannot simply copy TextEdit out cange it then replace the original because you get an error that says TextEdit is required and cannot be deleted.


and when I do manage to edit that info list - then TextEdit crashes - although it might not if I get the bundle register thing to work.

Feb 26, 2012 10:01 AM in response to Matt Wolanski

and when I do manage to edit that info list - then TextEdit crashes


It may no longer be possible to hack into the info.plist of an Apple-supplied application because these apps are protected by "code signatures".


I made a copy of Lion's TextEdit.app on my Desktop, and this copy launched normally. I then made an insignificant change to its info.plist, changing a copyright date from 1995 to 1996. The app copy would no longer launch, and the TextEdit crash report in Console included:

---------

Crashed Thread: 0 Dispatch queue: com.apple.main-thread


Exception Type: EXC_BAD_INSTRUCTION (SIGILL)

Exception Codes: 0x0000000000000001, 0x0000000000000000


Application Specific Information:

dyld: launch, running initializers

/usr/lib/libSystem.B.dylib

xpchelper reply message validation: code signature invalid

The code signature is not valid: The operation couldn’t be completed. (OSStatus error -67061.)


Application Specific Signatures:

code signature invalid

--------------------


I then changed the copyright date entry back to 1995, and the app copy again launched normally.

Feb 26, 2012 10:25 AM in response to red_menace

That seems to have worked - at least in the case where I put my own rtf icon into Text Edit - but the output file still shows the original icn so maybe I am still missing a step - and no luck so far editing the plist with plist editor and getting textedit to run. The title bar in TextEdit shows the custom icon - but the saved file does not.


I have developer tools - maybe what I need to do is create my own app from scratch - and then build into it instructions for telling other apps to open the file in question.


The other option might be to set an automated folder task to change the custom icons on each file type as they are created.


sorting the files into folders by type is not a good option for me - I have 60,000+ files and they are sorted by file name where each group of 5 files have the same name.

Feb 26, 2012 1:07 PM in response to Matt Wolanski

Good luck, but I think you are fighting the system, which mainly uses file structure and metadata to identify things. The idea is that each application tells the system what kinds of files it can handle, and the icons to use for the files that it can create/edit. If the application is the default for a particular kind of file, then that is also usually where the icon comes from.


As mentioned, you are also looking at dealing with code signing and various sandboxing methods, so mangling an existing application probably isn't going to work much longer, if it does at all now. It is easy enough for an application or script to assign custom icons, so a folder action or perhaps a utility in the Finder's toolbar is the way to go.

Feb 26, 2012 2:04 PM in response to red_menace

I hear ya - and why I am asking - no point spending a lot of time and effort if it is only going to have to be repeated over and over with every update etc. Mainly looking to see if there is some simple answer that I am overlooking.


it is just that I would rather see this:


User uploaded file

http://homepage.mac.com/mattwolanski/customicons.jpg


than this:

User uploaded filehttp://homepage.mac.com/mattwolanski/defaulticons.jpg



durn it - how do you get the proper html tags for an inline graphic on these forums?

Feb 26, 2012 3:39 PM in response to Matt Wolanski

I am guessing that you have the desired icons, and I have some scripts that will set icons, so it sounds like it may just be a matter of defining a workflow that will work to apply them to the files.


To include an image when composing your reply, highlight the text you want to use for your link and click on the camera icon (at the top of the editor box).

Feb 26, 2012 6:47 PM in response to red_menace

Cool - must have tried every other option except the camera button.


Yes I have the icons - created myself - i have not worked out the scripts to set the icons - or the workflow.


at the moment I can copy the custom icon from one doc to the next - that might be an easy workflow to create - but woudl be better I think to poitn the a script at an icon file rather than have to copy from a reference doc each time.


Default icons:

User uploaded file

Custom icons:

User uploaded file

I have used very plain simply flat cutom icons for years on Windows - now using a Mac as my native enviro for work - but still need Windows for certain apps that are windows only - and wanted to create some more useful - more graphical icons for dealing with those icons on the Mac side of things.

Feb 26, 2012 8:41 PM in response to Matt Wolanski

A new Cocoa-AppleScript application can be created from the AppleScript Editor > File > New from Template > Cocoa-AppleScript Applet menu item, pasting in the following script:

-- set icon
on run -- application double-clicked
tell current application's NSOpenPanel's openPanel()
setFloatingPanel_(true)
setTitle_("Choose file items to set an icon for:")
setPrompt_("Choose") -- the button name
setDirectoryURL_(current application's NSURL's URLWithString_(POSIX path of (path to desktop)))

setCanChooseFiles_(true)
setCanChooseDirectories_(false)
setShowsHiddenFiles_(false)
setTreatsFilePackagesAsDirectories_(false)
setAllowsMultipleSelection_(true)

set theResult to runModal() as integer
if theResult is current application's NSFileHandlingPanelCancelButton then tell me to quit -- cancel button
set theFiles to URLs() as list
end tell

repeat with eachFile in theFiles -- coerce the file paths in place
tell eachFile to set its contents to its |path|() as text
end repeat
open theFiles
end run
on open theItems -- items dropped onto the application
try -- get a path to the image to be used for the icon
set imageFile to POSIX path of (choose file with prompt "Select an image file for the icon:" of type "public.image")
on error -- cancel button
tell me to quit
end try

set errorList to {} -- this will be a list of problem files, if any
repeat with eachItem in theItems
if not setIcon(imageFile, eachItem) then
set end of errorList to (eachItem & return)
end if
end repeat

if errorList is not {} then -- oops, show items where there was a problem
display alert "Error setting icon." message "Icons of the following items were not set:" & return & return & errorList as text
end if

tell me to quit -- done
end open
to setIcon(imageFilePath, fileItemPath) -- set the icon of a file item
set mySharedWorkspace to current application's NSWorkspace's sharedWorkspace()
set myImage to current application's NSImage's alloc's initWithContentsOfFile_(imageFilePath)
try
return mySharedWorkspace's setIcon_forFile_options_(myImage, fileItemPath, 0) as boolean
on error errorMessage
return false
end try
end setIcon

After saving, the resulting application can be double-clicked, or you can drop files onto it (the script can't be run from the script editor). It can be tweaked further to include image files in the application bundle to select from (the icon images can be any image, not just icon files), or to be used in the Finder's toolbar, but for now the basic application should get you started.

Mar 14, 2012 6:36 AM in response to red_menace

Cool - that woks - although what I would really like is to have the extension automatically choose the icon to set. that is all .csv files will get the custom .csv icon and all pti files will get the custom pti icon etc.


Also I want to set it as a folder action so that all files created in the working folder automatically get their icons set.


The files are being created by a Windows app and will (or at least should) always have an extension.

Applying custom icons to all files of a type

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