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.