• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting a File or Folder Icon via AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a File or Folder Icon via AppleScript


  • Subject: Re: Setting a File or Folder Icon via AppleScript
  • From: Iurista GmbH <email@hidden>
  • Date: Wed, 14 Jun 2017 00:20:18 +0200

Am 07.06.2017 um 06.32 schrieb Christopher Stone:

> Hey Folks,
>
> I think it is not possible to set a file or folder icon using vanilla
> AppleScript – true?
>
> At the moment I want to use a .icns file to set an app's icon.
>
> Can anyone help?
>
> TIA.
>
> --
> Best Regards,
Chris


Hi Chris,

maybe too late, but this works here (it changes the icon of one or multiple
selected applets, one by one.
It may need little adaptations for other apps than applets...

Note: The AIC script and an .icns file named Alias.icns have to be in the same
folder, and I call the script by QuicKeys.


#AppletIconChanger (AIC), a script to change applet icons
#est. 11.11.16, ©rod

tell application "Finder" to set sel to selection
repeat with i from 1 to number of items of sel
        set theAPP to item i of sel
        if not name extension of theAPP = "app" then return

        set RES to ((theAPP as text) & ":Contents:Resources:")
        set ppRES to POSIX path of RES

        set PDN to ((theAPP as text) & ":Contents:Info")
        set ppPDN to quoted form of (POSIX path of PDN)

        set kid to "CFBundleName"
        set APPName to (displayed name of theAPP) as text
        try
                do shell script ("defaults write " & ppPDN & " " & kid & " " &
quoted form of APPName)
        on error {errnum, errmsg}
                tell application "Finder" to display dialog return & "Fehler:
  " & errnum & return & "Text:        " & errmsg & return & return
                return
        end try

        set kid to "CFBundleIconFile"
        try
                do shell script ("defaults write " & ppPDN & " " & kid & " " &
"Alias.icns")
        on error {errnum, errmsg}
                tell application "Finder" to display dialog return & "Fehler:
  " & errnum & return & "Text:        " & errmsg & return & return
                return
        end try

        set TIFN to "Alias.icns" --
                                        TheIconFileName
        set myPath to POSIX file (POSIX path of ((path to me as text) & "::"))
as text
        set TIF to (myPath & TIFN) as alias

        try
                tell application "Finder" to delete item "droplet.icns" of
folder RES
        end try
        try
                tell application "Finder" to delete item "applet.icns" of
folder RES
        end try
        delay 0.5
        tell application "Finder" to duplicate TIF to folder RES replacing yes
end repeat


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Setting a File or Folder Icon via AppleScript (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Comma delimited paragraph Ver2
  • Next by Date: Permissions problem mac OS X 10.9.5 server
  • Previous by thread: Re: Setting a File or Folder Icon via AppleScript
  • Next by thread: Re: Setting a File or Folder Icon via AppleScript
  • Index(es):
    • Date
    • Thread