How do I solve the error “Couldn’t set the custom file icon”?

Custom directory icons can be set in the Finder by opening the Info panel (from the main menu View > Get Info, or by pressing Command-I) and dragging an image onto the icon on the top left of the Info panel. A custom icon can be removed again by clicking it in the Info panel and pressing the Delete key.

Check for custom file icons

If you’re getting the error “Couldn’t set the custom file icon” but you cannot see a custom icon set in the Finder, you can check if there is a custom icon with the following steps:

  1. Open the Terminal (in /Applications/Utilities).
  2. Type “ls -a ” (with a trailing whitespace), then drag the directory mentioned in the error message into the Finder window. Press Enter. This command lists all contents of the dragged directory, including hidden files. A custom directory icon is saved inside the directory itself as a hidden file named “Icon\r”, where “\r” stands for the carriage return character and is displayed in the Finder as a “?” character.

Delete custom file icons

If you’re syncing a directory with a volume that doesn’t support custom icons, you can find and optionally delete all the custom icons with the following steps:

  1. Open the Terminal (in /Applications/Utilities).
  2. Type “cd ” (with a trailing whitespace), then drag the root directory into the Finder window. Press Enter. This command makes the dragged directory the current directory in the Terminal.
  3. Copy and paste the command
    find . -name "Icon?" -type f
    into the Terminal window and press Enter. This command lists all files with the name “Icon”, followed by any other character. In the find command, ? matches any character, which we use to replace the “\r” character.
  4. Make sure that no unwanted file is listed.
  5. Copy and paste the command
    find . -name "Icon?" -type f -delete
    into the Terminal window and press Enter. This command deletes all files matched by the previous query.