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

harrisonjr98

macrumors 6502
Original poster
Dec 15, 2019
345
200
Here's the situation - I have an M1 Mini. These aren't system files like DS_Store or anything that I'm talking about! I had some MP3 files on a flash drive that I was going to upload to cloud storage and then archive on an external hard drive. I transferred them from the flash drive to my Mac and got to uploading, and then realized during the archival process that one of the (many) albums is "invisible" in Finder, despite having upload successfully (!!!) to the cloud storage. "Get Info" on the folder that contains the songs shows it as being 90MB, which is correct, but clicking into the folder shows no items. Moved the folder back to the flash drive - same deal. And yet, plugged the flash drive into my windows machine and they're perfectly visible. So they exist and the mac even moved them back and forth despite thinking there was nothing there. What could be happening here? I hate to think that my Mac might be hiding files from me.
 

joevt

macrumors 604
Jun 21, 2012
6,967
4,262
Press Command-Shift-Period to show/hide invisible files in macOS?

You should be able to use the ls -lA command to list invisible files in the current directory.

Maybe the files have the invisible flag set in their Finder Info?
You can use the xattr command to view the Finder Info flags (change path to the name of the file or folder)
xattr -px com.apple.FinderInfo path

The following shell functions can get and set the invisible flag:
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	
}

getfinderinfoflag () {
	local thepath="$1"
	local thechar="$2"
	local thebit="$3"
	local thefinderinfo=""
	thefinderinfo=$(xattr -px com.apple.FinderInfo "$thepath" 2> /dev/null | xxd -p -r | xxd -p -c 32)
	echo $(( ( 0x0${thefinderinfo:$thechar:1} >> thebit ) & 1 ))
}

setfoldercustomicon () {
	# if the folder is a mount point then the icon should be in datafork of ".VolumeIcon.icns"
	# otherwise the icon should be in a icns resource in "Icon\n"
	setfinderinfoflag "$1" 17 2 1
}

isfileinvisible () {
	getfinderinfoflag "$1" 16 2
}

setfilevisible () {
	setfinderinfoflag "$1" 16 2 0
}

setfileinvisible () {
	setfinderinfoflag "$1" 16 2 1
}

fixcustomiconflagofallvolumes () {
	IFS=$'\n'
	for themount in $(getallmounteddisks); do
		if [[ -f "$themount/.VolumeIcon.icns" ]]; then
			setfoldercustomicon "$themount"
		fi
	done
}

Then run the commands like this:
isfilevisible path # will output 1 if path is an invisible file or folder and 0 otherwise.
setfilevisible path # make the file or folder at path visible

Note that some files and folder are invisible not because of the FinderInfo flag, but because their name starts with a period ..

If they are invisible for some other reason, then maybe run Disk Utility First Aid on the volume.
 

harrisonjr98

macrumors 6502
Original poster
Dec 15, 2019
345
200
Press Command-Shift-Period to show/hide invisible files in macOS?

You should be able to use the ls -lA command to list invisible files in the current directory.

Maybe the files have the invisible flag set in their Finder Info?
You can use the xattr command to view the Finder Info flags (change path to the name of the file or folder)
xattr -px com.apple.FinderInfo path

The following shell functions can get and set the invisible flag:
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   
}

getfinderinfoflag () {
    local thepath="$1"
    local thechar="$2"
    local thebit="$3"
    local thefinderinfo=""
    thefinderinfo=$(xattr -px com.apple.FinderInfo "$thepath" 2> /dev/null | xxd -p -r | xxd -p -c 32)
    echo $(( ( 0x0${thefinderinfo:$thechar:1} >> thebit ) & 1 ))
}

setfoldercustomicon () {
    # if the folder is a mount point then the icon should be in datafork of ".VolumeIcon.icns"
    # otherwise the icon should be in a icns resource in "Icon\n"
    setfinderinfoflag "$1" 17 2 1
}

isfileinvisible () {
    getfinderinfoflag "$1" 16 2
}

setfilevisible () {
    setfinderinfoflag "$1" 16 2 0
}

setfileinvisible () {
    setfinderinfoflag "$1" 16 2 1
}

fixcustomiconflagofallvolumes () {
    IFS=$'\n'
    for themount in $(getallmounteddisks); do
        if [[ -f "$themount/.VolumeIcon.icns" ]]; then
            setfoldercustomicon "$themount"
        fi
    done
}

Then run the commands like this:
isfilevisible path # will output 1 if path is an invisible file or folder and 0 otherwise.
setfilevisible path # make the file or folder at path visible

Note that some files and folder are invisible not because of the FinderInfo flag, but because their name starts with a period ..

If they are invisible for some other reason, then maybe run Disk Utility First Aid on the volume.
Annnnd I'm officially a giant idiot. They were hidden because the name of the record starts with "...," and it didn't even occur to me that macOS (or its unix underpinnings) would hide all files and even folders starting with a full stop.
 

joevt

macrumors 604
Jun 21, 2012
6,967
4,262
On a Mac, you can type an ellipsis … by typing Option ;
(hold the Option key down and press the semicolon key).

Or if you want to stick with regular ASCII, then maybe you could put a space before the first period.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.