Terminal command to remove custom icon from file (HFS+)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












Context



In Mac OS X / macOS you can select a file in the Finder, click Informations then click the icon, and paste any image/icon that is in the clipboard. Now this file has a custom icon made of this image.



To remove it, the usual way is to select the file, click Informations, select the custom icon then hit delete and it removes the custom icon, restoring the default one.



Question



Is there a way to remove these custom icons from these files without having to open a Finder window? For example with a Terminal command?



Why



A file has a corrupted custom icon, opening the Finder in this folder causes the Finder to beachball and the HDD to freak out. But I still can access the folder content, and this file, from the command line, if I don't first open a Finder window. So I'm thinking that I "just" need to access the metadata differently to remove the custom icon.










share|improve this question

























    up vote
    3
    down vote

    favorite












    Context



    In Mac OS X / macOS you can select a file in the Finder, click Informations then click the icon, and paste any image/icon that is in the clipboard. Now this file has a custom icon made of this image.



    To remove it, the usual way is to select the file, click Informations, select the custom icon then hit delete and it removes the custom icon, restoring the default one.



    Question



    Is there a way to remove these custom icons from these files without having to open a Finder window? For example with a Terminal command?



    Why



    A file has a corrupted custom icon, opening the Finder in this folder causes the Finder to beachball and the HDD to freak out. But I still can access the folder content, and this file, from the command line, if I don't first open a Finder window. So I'm thinking that I "just" need to access the metadata differently to remove the custom icon.










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Context



      In Mac OS X / macOS you can select a file in the Finder, click Informations then click the icon, and paste any image/icon that is in the clipboard. Now this file has a custom icon made of this image.



      To remove it, the usual way is to select the file, click Informations, select the custom icon then hit delete and it removes the custom icon, restoring the default one.



      Question



      Is there a way to remove these custom icons from these files without having to open a Finder window? For example with a Terminal command?



      Why



      A file has a corrupted custom icon, opening the Finder in this folder causes the Finder to beachball and the HDD to freak out. But I still can access the folder content, and this file, from the command line, if I don't first open a Finder window. So I'm thinking that I "just" need to access the metadata differently to remove the custom icon.










      share|improve this question













      Context



      In Mac OS X / macOS you can select a file in the Finder, click Informations then click the icon, and paste any image/icon that is in the clipboard. Now this file has a custom icon made of this image.



      To remove it, the usual way is to select the file, click Informations, select the custom icon then hit delete and it removes the custom icon, restoring the default one.



      Question



      Is there a way to remove these custom icons from these files without having to open a Finder window? For example with a Terminal command?



      Why



      A file has a corrupted custom icon, opening the Finder in this folder causes the Finder to beachball and the HDD to freak out. But I still can access the folder content, and this file, from the command line, if I don't first open a Finder window. So I'm thinking that I "just" need to access the metadata differently to remove the custom icon.







      macos finder command-line filesystem hfs+






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Moritz

      1568




      1568




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          For files with custom icon, use the following command:



          xattr -d com.apple.ResourceFork /path/to/filename



          For folders with custom icon, in Terminal, change directory to the folder containing the custom icon, e.g.:



          cd /path/to/foo


          Once in the directory, use the following command to remove the custom icon:



          rm Icon?





          share|improve this answer






















          • Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
            – Moritz
            1 hour ago










          • @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
            – user3439894
            57 mins ago






          • 1




            Exactly what I needed. Thank you!
            – Moritz
            52 mins ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "118"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f338823%2fterminal-command-to-remove-custom-icon-from-file-hfs%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          For files with custom icon, use the following command:



          xattr -d com.apple.ResourceFork /path/to/filename



          For folders with custom icon, in Terminal, change directory to the folder containing the custom icon, e.g.:



          cd /path/to/foo


          Once in the directory, use the following command to remove the custom icon:



          rm Icon?





          share|improve this answer






















          • Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
            – Moritz
            1 hour ago










          • @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
            – user3439894
            57 mins ago






          • 1




            Exactly what I needed. Thank you!
            – Moritz
            52 mins ago














          up vote
          2
          down vote



          accepted










          For files with custom icon, use the following command:



          xattr -d com.apple.ResourceFork /path/to/filename



          For folders with custom icon, in Terminal, change directory to the folder containing the custom icon, e.g.:



          cd /path/to/foo


          Once in the directory, use the following command to remove the custom icon:



          rm Icon?





          share|improve this answer






















          • Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
            – Moritz
            1 hour ago










          • @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
            – user3439894
            57 mins ago






          • 1




            Exactly what I needed. Thank you!
            – Moritz
            52 mins ago












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          For files with custom icon, use the following command:



          xattr -d com.apple.ResourceFork /path/to/filename



          For folders with custom icon, in Terminal, change directory to the folder containing the custom icon, e.g.:



          cd /path/to/foo


          Once in the directory, use the following command to remove the custom icon:



          rm Icon?





          share|improve this answer














          For files with custom icon, use the following command:



          xattr -d com.apple.ResourceFork /path/to/filename



          For folders with custom icon, in Terminal, change directory to the folder containing the custom icon, e.g.:



          cd /path/to/foo


          Once in the directory, use the following command to remove the custom icon:



          rm Icon?






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 48 mins ago

























          answered 1 hour ago









          user3439894

          25.6k63656




          25.6k63656











          • Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
            – Moritz
            1 hour ago










          • @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
            – user3439894
            57 mins ago






          • 1




            Exactly what I needed. Thank you!
            – Moritz
            52 mins ago
















          • Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
            – Moritz
            1 hour ago










          • @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
            – user3439894
            57 mins ago






          • 1




            Exactly what I needed. Thank you!
            – Moritz
            52 mins ago















          Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
          – Moritz
          1 hour ago




          Thanks, but in my case I have files (not folders) with custom icons, so I can't do that, right?
          – Moritz
          1 hour ago












          @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
          – user3439894
          57 mins ago




          @Moritz, I've updated my answer to cover files instead of folders however, I left to original part of the answer as I believe it will also be helpful to others.
          – user3439894
          57 mins ago




          1




          1




          Exactly what I needed. Thank you!
          – Moritz
          52 mins ago




          Exactly what I needed. Thank you!
          – Moritz
          52 mins ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f338823%2fterminal-command-to-remove-custom-icon-from-file-hfs%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          White Anglo-Saxon Protestant

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          One-line joke