An AppleScript to reinstall custom icons after updates

Nov 20, '09 07:30:04AM

Contributed by: Andrew J Freyer

Like many people, I have customized many thing about my OS X setup, not the least of which were app and folder icons. Via programs like CandyBar or LiteIcon, or manually, any and all folder/file/app icons can be changed.

Personally, I like the pure|icns set from Interfacelift. However, there is a problem when programs update -- in my case, Dropbox -- and change their icons back to a boring old Leopard blue. To return my custom icons, I wrote an AppleScript. Since this only happens every now and then, I didn't make the script executable; I just call it from Google's quick search box whenever I need it.

At any rate, this script will copy an icon from some location (file, folder, *.icns), and paste it via the Get Info window for any second location (file, folder, app) that you desire. Of course, change the first two POSIX paths to (1) where the icon should come from, and (2) where the icon should go.

set newIcon to (POSIX file "/this/is/the/path/to/the/icon") as alias
set theItem to (POSIX file "/this/is/the/path/to/the/location") as alias

tell application "Finder"
  activate
  set infoWindow to open information window of newIcon
  set infoWindowName to name of infoWindow
end tell

tell application "System Events"
  tell application process "Finder"
    tell window infoWindowName
      keystroke tab
      delay 1
      keystroke "c" using command down
    end tell
  end tell
end tell

tell application "Finder"
  close infoWindow
  set infoWindow to open information window of theItem
  set infoWindowName to name of infoWindow
end tell

tell application "System Events"
  tell application process "Finder"
    tell window infoWindowName
      keystroke tab
      delay 1
      keystroke "v" using command down
    end tell
  end tell
end tell

tell application "Finder"
  close infoWindow
end tell
This script contains modified code from this script.

[robg adds: I haven't tested this one.]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20091111215845472