10 Replies Latest reply: Feb 11, 2013 8:41 AM by softwater
Dorkowang Level 1 Level 1 (0 points)

I cannot manage to change the icon for my .pl files in OS X 10.7.5

 

This works:

 

I have perl scripts which have the extension .pl. I edit them with BBEdit and run them in the terminal.app. The scripts contains a shebang line and I have assigned all .pl extension to open with the terminal. So clicking on a .pl file runs the perl script.

 

This is what I want:

 

I would like all .pl files to have the same icon, so I can recognize them immediately as such. The assignment of the Icon should automatically happen when I generate a file, as I am to lazy to change the Icons manually for each file. (I know how to do this)

 

 

This is what I did, but does not work:

 

I got a .jpg file which I converted to png and renamed to PerlIcon.icns

 

Inside the terminal.app package I saved latter file into the folder Contents/Resources/

 

In the Info.plist file I also included following code inside <key>CFBundleDocumentTyper<key><array> ... </array>:

 

            <dict>

            <key>CFBundleTypeExtensions</key>

            <array>

                       <string>pl</string>

            </array>

            <key>CFBundleTypeIconFile</key>

            <string>PerlIcon.icns</string>

            <key>CFBundleTypeName</key>

            <string>Perl Script</string>

            <key>CFBundleTypeRole</key>

            <string>Viewer</string>

            </dict>

           

This is not working. I also changed "PerlIcon.icns" to "PerlIcon" and/or "Viewer" to "Editor".

           

As this is also not working. I tried the same with the BBEdit application package, but still I do not get the icon assignement I want.

 

What am I doing wrong?

 

Many thanks for any help

 

Claudio


Mac OS X (10.7.2)
  • 1. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    You can't create a valid .icns file just by changing a jpg file extension. You have to use the iconutil utility in Terminal after you have made an iconset folder.

     

    I wrote a tutorial up for how to do this here:

     

    http://applehelpwriter.com/2012/12/16/make-your-own-icns-icons-for-free/

     

    (ToU Disclaimer: this links to my personal website).

  • 2. Re: How do I permanently change the icons for .xyz files?
    Dorkowang Level 1 Level 1 (0 points)

    Thank you very much. My assumption that just changing the .png extension to .icns would be enough was indeed wrong. I have now made an icon following the excellent tutorial mentioned above. The icon is working, as I was able to check with the trick of renaming it so that it has the same name as the icon previously used by an application. Nevertheless in my code there still must be a bug as I still cannot change the .pl files to get my icon.

  • 3. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    Looks like that 'r' is wrong at the end of 'CFBundleDocumentTyper'

     

    In the Info.plist file I also included following code inside <key>CFBundleDocumentTyper<key><array> ... </array>:

     

     

    Shouldn't that 'r' be an 's'?

     

    <key>CFBundleDocumentTypes<key><array> ... </array>:

  • 4. Re: How do I permanently change the icons for .xyz files?
    Dorkowang Level 1 Level 1 (0 points)

    Ups...Sorry!!! That was a typo when writing up the question. In the Info.plist that is correct. Here the code copy-pasted as it is. In italics the code I inserted.

     

    ...

    <key>CFBundleDevelopmentRegion</key>

              <string>English</string>

              <key>CFBundleDocumentTypes</key>

              <array>

                        <dict>

                <key>CFBundleTypeExtensions</key>

                <array>

                          <string>pl</string>

                </array>

                <key>CFBundleTypeIconFile</key>

                <string>PerlIcon</string>

                <key>CFBundleTypeName</key>

                <string>Perl Script</string>

                <key>CFBundleTypeRole</key>

                <string>Viewer</string>

            </dict>

                        <dict>

                                  <key>CFBundleTypeIconFile</key>

                                  <string>BBEditTextDocument.icns</string>

                                  <key>CFBundleTypeName</key>

    ....

  • 5. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    You have

     

    <string>Perl Script</string>

     

    I don't believe you can have a space in the string. Try wrapping it in double quotes, like this:

     

    <string>"Perl Script"</string>

  • 6. Re: How do I permanently change the icons for .xyz files?
    Dorkowang Level 1 Level 1 (0 points)

    I changed the name to PerlScript, but that does not seemto help

  • 7. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    Did you log out and log back in again? You need to let the system reload all the plist files.

  • 8. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    I'm also not sure why you're putting this in the Terminal.app info plist.

     

    Have you associated all .pl files to be opened with Terminal in a .pl file's 'Get Info' box?

  • 9. Re: How do I permanently change the icons for .xyz files?
    Dorkowang Level 1 Level 1 (0 points)

    I tried to play around with bothm the plists from BBEdit and from the terminal. I do create the files with BBEdit but I launch them with the terminal, to which they are associated.

     

    By searching through the web I found somebody that had a very similar problem so I used his code to check. In the BBEdit Infolist i changed my code with:

     

    <dict>

                                  <key>CFBundleTypeExtensions</key>

                                  <array>

                                            <string>pce</string>

                                  </array>

                                  <key>CFBundleTypeIconFile</key>

                                  <string>pce.icns</string>

                                  <key>CFBundleTypeName</key>

                                  <string>PCE ROM</string>

                                  <key>CFBundleTypeRole</key>

                                  <string>Viewer</string>

                                  <key>NSDocumentClass</key>

                                  <string>MEPCEROM</string>

                        </dict>

     

    Furthermore I changed the name of my icns file to pce.icns and run following commands on the terminal:

     

    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchSe rvices.framework/Versions/A/Support/lsregister -f /Applications/BBEdit.app

     

    and

     

    killall  Finder; killall Dock;

     

    After this if I renamed a file to have a .pce extension that file got the icon I wanted.

     

    But if I now changed the plist so that instead of "pce" the extension would be "pl" and run the lsregister and killall commands, then the association of .pl files with my icon is not happening.

     

    I can exclude that the behavior is due to the two characters lenght of the extension, as when I use a .cv extension everything works again. There must be something that has a handle on the .pl extension and does not allwo me to take them over. So the problem is not my code, but the fact that I want to use .pl

     

    Any other idea besides using another extension for my perl script files?

  • 10. Re: How do I permanently change the icons for .xyz files?
    softwater Level 5 Level 5 (5,370 points)

    No, sorry. Nothing I can think of right now.

     

    I'd imagine the by default Xcode would be the run handler for perl scripts, but I'm not sure if that helps you in any way.