Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Wolfmann2904

macrumors newbie
Original poster
Jun 14, 2016
13
8
Copenhagen
I simply can't change Documents folder icon in my home directory. All other folder icons can be easily changed. The ownership and privilege are missing in the Document folder info. See the attached screenshot.

Screenshot 2021-05-10 at 15.08.17.png


ls -l in Terminal give me this:

Screenshot 2021-05-10 at 17.53.03.png


Documents folder doesn't have sign @ , which means extended file attributes relating to security are missing, instead it has + sign.

Anyone knows how to fix this?
 

joevt

macrumors 604
Jun 21, 2012
6,938
4,239
The man page for ls (in Terminal.app, type ls, right click the word "ls", and select "Open man Page") says that the + character indicates an ACL (Access Control List).
The man page says the -e option will show the ACL.

Code:
cd ~
ls -l | grep +
ls -lde Documents Movies Music Pictures Sites
The -d option will list a directory without listing its contents (treats arguments as files)

I would try researching commands to modify ACL (if necessary) - I guess check the man page for chmod

One thing you can do is paste the icon to a new folder, then use commands to move the icon to the destination folder. Say the folder is ~/MyFolderWithCustomIcon and you want to copy its icon to ~/Documents :

Code:
setfinderinfoflag () {
	local thepath="$1"
	local thechar="$2"
	local thebit="$3"
	local thevalue="$4"
	local thefinderinfo=""
	local newfinderinfo=""
	local thedescription=""
	thefinderinfo=$(xattr -px com.apple.FinderInfo "$thepath" 2> /dev/null | xxd -p -r | xxd -p -c 32)
	if [[ -z "$thefinderinfo" ]]; then
		thefinderinfo="0000000000000000000000000000000000000000000000000000000000000000"
		thedescription="nonexistant "
	fi
	newfinderinfo=${thefinderinfo:0:$thechar}$( printf "%x" $(( ${thefinderinfo:$thechar:1} & (~(1<<(thebit))) | (thevalue<<(thebit)) )) )${thefinderinfo:$((thechar+1))}
	if [[ "$newfinderinfo" != "$thefinderinfo" ]]; then
		echo "# modifying ${thedescription}FinderInfo $newfinderinfo $thepath"
		xattr -wx com.apple.FinderInfo "$newfinderinfo" "$thepath"
	else
		echo "# unchanged ${thedescription}FinderInfo $newfinderinfo $thepath"
	fi	
}

setfoldercustomicon () {
	setfinderinfoflag "$1" 17 2 1
}

cp ~/MyFolderWithCustomIcon/Icon$'\r' ~/Documents
setfoldercustomicon ~/Documents

$'\r' is a carriage return character (ASCII 0x0D = 13 = Control-M) - Apple uses this for files that it doesn't want the user to mess with because it's difficult to enter a file name that includes a carriage return character in the UI. The Finder shows the character as ? (if you've enabled showing invisible files with Command-Shift-Period). The Icon$'\r' file uses a resource fork (accessible as one of the extended attributes) to store icons (either icns or older icon resource types which can be listed with derez). The root folder of a volume uses a file named .VolumeIcon.icns which uses a different format for the icon (the icns is in the data fork as an icns icon type instead of the resource fork).
 
Last edited:
  • Like
Reactions: Wolfmann2904

Wolfmann2904

macrumors newbie
Original poster
Jun 14, 2016
13
8
Copenhagen
The man page for ls (in Terminal.app, type ls, right click the word "ls", and select "Open man Page") says that the + character indicates an ACL (Access Control List).
The man page says the -e option will show the ACL.

Code:
cd ~
ls -l | grep +
ls -lde Documents Movies Music Pictures Sites
The -d option will list a directory without listing its contents (treats arguments as files)

I would try researching commands to modify ACL (if necessary) - I guess check the man page for chmod

One thing you can do is paste the icon to a new folder, then use commands to move the icon to the destination folder. Say the folder is ~/MyFolderWithCustomIcon and you want to copy its icon to ~/Documents :

Code:
setfinderinfoflag () {
    local thepath="$1"
    local thechar="$2"
    local thebit="$3"
    local thevalue="$4"
    local thefinderinfo=""
    local newfinderinfo=""
    local thedescription=""
    thefinderinfo=$(xattr -px com.apple.FinderInfo "$thepath" 2> /dev/null | xxd -p -r | xxd -p -c 32)
    if [[ -z "$thefinderinfo" ]]; then
        thefinderinfo="0000000000000000000000000000000000000000000000000000000000000000"
        thedescription="nonexistant "
    fi
    newfinderinfo=${thefinderinfo:0:$thechar}$( printf "%x" $(( ${thefinderinfo:$thechar:1} & (~(1<<(thebit))) | (thevalue<<(thebit)) )) )${thefinderinfo:$((thechar+1))}
    if [[ "$newfinderinfo" != "$thefinderinfo" ]]; then
        echo "# modifying ${thedescription}FinderInfo $newfinderinfo $thepath"
        xattr -wx com.apple.FinderInfo "$newfinderinfo" "$thepath"
    else
        echo "# unchanged ${thedescription}FinderInfo $newfinderinfo $thepath"
    fi   
}

setfoldercustomicon () {
    setfinderinfoflag "$1" 17 2 1
}

cp ~/MyFolderWithCustomIcon/Icon$'\r' ~/Documents
setfoldercustomicon ~/Documents

$'\r' is a carriage return character (ASCII 0x0D = 13 = Control-M) - Apple uses this for files that it doesn't want the user to mess with because it's difficult to enter a file name that includes a carriage return character in the UI. The Finder shows the character as ? (if you've enabled showing invisible files with Command-Shift-Period). The Icon$'\r' file uses a resource fork (accessible as one of the extended attributes) to store icons (either icns or older icon resource types which can be listed with derez). The root folder of a volume uses a file named .VolumeIcon.icns which uses a different format for the icon (the icns is in the data fork as an icns icon type instead of the resource fork).

Thanks for your answer, though I don't understand much of what you wrote 😥. Is that a shell script that would allow me to change the Documents folder icon?

Do you know why have Apple decided not to allow us to change Documents folder icon, and allow us to change all other icons? It doesn't make sense. Initially I thought it was my fault, but today I did a clean install and it's the same - I simply can't change permissions of Documents folder.
 

joevt

macrumors 604
Jun 21, 2012
6,938
4,239
Thanks for your answer, though I don't understand much of what you wrote 😥. Is that a shell script that would allow me to change the Documents folder icon?
Yes, it's a shell script. It creates two functions (temporary - while the Terminal.app window is open): setfinderinfoflag sets a finder info flag of a file or folder; setfoldercustomicon sets the folder custom icon finder info flag for a folder. Then there's a cp command to copy the custom icon from the ~/MyFolderWithCustomIcon folder to the Documents folder. The last command uses setfoldercustomicon to set the folder custom icon flag of the Documents folder.

There might be a permission error? But if there is, at least it may be more informative than what you're currently getting.

Do you know why have Apple decided not to allow us to change Documents folder icon, and allow us to change all other icons? It doesn't make sense. Initially I thought it was my fault, but today I did a clean install and it's the same - I simply can't change permissions of Documents folder.
I don't know. Maybe it's a iCloud thing?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.