Terminal command to remove custom icon from file (HFS+)
Clash 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.
macos finder command-line filesystem hfs+
add a comment |Â
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.
macos finder command-line filesystem hfs+
add a comment |Â
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.
macos finder command-line filesystem hfs+
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+
macos finder command-line filesystem hfs+
asked yesterday
Moritz
1568
1568
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
For files with a custom icon, macOS writes the icon data as a resource fork to the file. Use the xattr
command in the following form:
xattr -d com.apple.ResourceFork /path/to/filename
For more information about the xattr
command, in Terminal type the following command and press: enter
man xattr
Or just type xattr
and then right-click on it and select: Open man Page
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?
Note that you can also just use:
rm /path/to/foo/Icon?
However, you cannot use quotes, single or double, if the pathname has spaces and must escape the spaces with a backslash, , e.g.:
rm /path/to/foo bar/Icon?
Quoting the pathname will just return the following error:
: No such file or directory
By default, Icon?
is a hidden file and the ?
in Icon?
is actually a linefeed, n
, character.
1
Exactly what I needed. Thank you!
â Moritz
yesterday
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
For files with a custom icon, macOS writes the icon data as a resource fork to the file. Use the xattr
command in the following form:
xattr -d com.apple.ResourceFork /path/to/filename
For more information about the xattr
command, in Terminal type the following command and press: enter
man xattr
Or just type xattr
and then right-click on it and select: Open man Page
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?
Note that you can also just use:
rm /path/to/foo/Icon?
However, you cannot use quotes, single or double, if the pathname has spaces and must escape the spaces with a backslash, , e.g.:
rm /path/to/foo bar/Icon?
Quoting the pathname will just return the following error:
: No such file or directory
By default, Icon?
is a hidden file and the ?
in Icon?
is actually a linefeed, n
, character.
1
Exactly what I needed. Thank you!
â Moritz
yesterday
add a comment |Â
up vote
3
down vote
accepted
For files with a custom icon, macOS writes the icon data as a resource fork to the file. Use the xattr
command in the following form:
xattr -d com.apple.ResourceFork /path/to/filename
For more information about the xattr
command, in Terminal type the following command and press: enter
man xattr
Or just type xattr
and then right-click on it and select: Open man Page
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?
Note that you can also just use:
rm /path/to/foo/Icon?
However, you cannot use quotes, single or double, if the pathname has spaces and must escape the spaces with a backslash, , e.g.:
rm /path/to/foo bar/Icon?
Quoting the pathname will just return the following error:
: No such file or directory
By default, Icon?
is a hidden file and the ?
in Icon?
is actually a linefeed, n
, character.
1
Exactly what I needed. Thank you!
â Moritz
yesterday
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
For files with a custom icon, macOS writes the icon data as a resource fork to the file. Use the xattr
command in the following form:
xattr -d com.apple.ResourceFork /path/to/filename
For more information about the xattr
command, in Terminal type the following command and press: enter
man xattr
Or just type xattr
and then right-click on it and select: Open man Page
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?
Note that you can also just use:
rm /path/to/foo/Icon?
However, you cannot use quotes, single or double, if the pathname has spaces and must escape the spaces with a backslash, , e.g.:
rm /path/to/foo bar/Icon?
Quoting the pathname will just return the following error:
: No such file or directory
By default, Icon?
is a hidden file and the ?
in Icon?
is actually a linefeed, n
, character.
For files with a custom icon, macOS writes the icon data as a resource fork to the file. Use the xattr
command in the following form:
xattr -d com.apple.ResourceFork /path/to/filename
For more information about the xattr
command, in Terminal type the following command and press: enter
man xattr
Or just type xattr
and then right-click on it and select: Open man Page
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?
Note that you can also just use:
rm /path/to/foo/Icon?
However, you cannot use quotes, single or double, if the pathname has spaces and must escape the spaces with a backslash, , e.g.:
rm /path/to/foo bar/Icon?
Quoting the pathname will just return the following error:
: No such file or directory
By default, Icon?
is a hidden file and the ?
in Icon?
is actually a linefeed, n
, character.
edited yesterday
answered yesterday
user3439894
25.6k63656
25.6k63656
1
Exactly what I needed. Thank you!
â Moritz
yesterday
add a comment |Â
1
Exactly what I needed. Thank you!
â Moritz
yesterday
1
1
Exactly what I needed. Thank you!
â Moritz
yesterday
Exactly what I needed. Thank you!
â Moritz
yesterday
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password