2

I recently ran a MacOS update and when it was finished... my Desktop was empty! Not only that, when I browsed to the Desktop folder, everything appeared to be gone. I save a lot of work to my desktop, so I had a minor panic attack thinking the update deleted my files.

After looking at my Recent Files list, I tried to open a few documents that I knew were stored on the Desktop. They still existed. After further exploration, I found that all files and folders on my Desktop were somehow flagged as hidden.

Again, I have a lot of files and folders on my desktop. I know of the chgflags unhidden ... command, but I have to call that for every single file and folder. I also know how to make hidden files visible within finder/terminal/Desktop UI, but I really would prefer to not have to do that and instead update each file and folder to not be hidden.

Is there a way to iterate through an entire directory and make all files permanently unhidden? Thanks.

EDIT

As requested, here are the results for running ls -lOe on one of the files.

RLHMBP:desktop rlh$ ls -lOe Vows.jpg 
-rw-------@ 1 rlh  staff  - 400525 Jul 16  2018 Vows.jpg 

nohillside mentioned that this file does not appear to be hidden. If that is the case, my Mac is not functioning that way.

If I open Finder and press Command+Shift+., these files show up as if they are hidden. If I Force Quit Finder and reopen it, the files are hidden again, and a Command+Shift+. causes them to show up again in Finder and on the Desktop.

nohillside had also recommended that I run chgflags unhidden * from within the Desktop folder within Terminal. When I execute the command, nothing is reported and I am kicked back to the prompt--a usual sign that the command worked properly. Regardless, I can't see these files.

I must re-iterate again that this morning I updated my machine. I try to keep it up to date, regardless. This was not happening, and has never happened, before a restart after the MacOS update.

EDIT #2

Here's a screenshot of the Get Info screen for the above file.

enter image description here

10
  • Can you add a screenshot of the „Get Info“ window of the same file?
    – nohillside
    Jan 6, 2022 at 18:45
  • @nohillside I added the requested SS.
    – RLH
    Jan 6, 2022 at 19:23
  • As well as the hidden flag, files can be hidden using extended attributes. Can you do xattr -px com.apple.FinderInfo <file> on one of your files (replacing the <file> with a real file).
    – Gilby
    Jan 6, 2022 at 22:45
  • If you open a Finder window and navigate to the Desktop folder, do you see the items? Are they only missing from the Desktop, or from the Desktop folder as well? Jan 7, 2022 at 0:58
  • 1
    Given that you have found chflags not to work, I have written up the xattr cause and how to fix it. It was a learning exercise for me!
    – Gilby
    Jan 7, 2022 at 6:30

2 Answers 2

3

@nohillside's answer is correct if the cause is that the unix hidden flag has been set. But there are other potential causes. Here is an answer that should be read in addition to @nohillside's answer.

macOS sets extended file attributes (xattr) on files. These include an attribute com.apple.FinderInfo which is used by Finder. It can be shown with:

xattr -px com.apple.FinderInfo <file> where the <file> is replaced by a file name and extension.

If the xattr is present it is 32 bytes long and displayed in hexadecimal, like this. Here is an example for a file called culinary.docx (it just happens to be on my Desktop):

% xattr -px com.apple.FinderInfo culinary.docx
57 58 42 4E 4D 53 57 44 40 10 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The bit represented by the 4 in the 9th byte (40) is the hidden or invisible bit.

The format of com.appleFinderInfo can be found in this header file Carbon Headers. Look for kIsInvisible. I will call it the "inVisible" bit.

One method of clearing the inVisible bit is to delete all extended attributes, like this: xattr -c <file> or to do it recursively: xattr -cr <folder>

But this is somewhat drastic and will, for example, remove the kIsAlias bit so that any aliases will no longer work! I am not sure what else.

There is a better method. It requires that you install the Xcode Command Line Tools. If you don't have these, you can install with: xcode-select –-install

You will then have the command GetFileInfo and SetFile (note the capitalisation). Please read the help pages man GetFileInfo and man SetFile. Here is an example:

% GetFileInfo -a culinary.docx
aVbstclinmEdz

The V indicates that the inVisible bit is set. In general the capitals are set bits. We can clear the inVisible with SetFile like this:

% SetFile -a v culinary.docx
% GetFileInfo -a culinary.docx
avbstclinmEdz

Now the inVisible bit is a small v and that indicates that it is not set.

Combine this with a find command and we can clear the inVisible bit for all files and folders in Desktop with:

find ~/Desktop -exec SetFile -a v {} \;

After running that all files and folders will be visible in Finder. You might need to choose another folder and then come back to ~/Desktop.

6
  • Ah, great, I didn't see the extended attributes (even though I asked for them :-)).
    – nohillside
    Jan 7, 2022 at 7:31
  • It works! Wow! I'm going to give you the answer mark, but any clue how or why this might happen? Another piece to the puzzle. A lot of people complain about having a missing desktop after an update. The solution for most is to cut off iCloud syncing. I have never, once, logged into iCloud. I'm too stubborn and happy with Google Drive. Any knowledge of how these attributes might have been set? Also, this happened only once by my Applications directory was "empty" too. I did another restarted and they appeared, but never the Desktop.
    – RLH
    Jan 7, 2022 at 14:21
  • Really glad it worked for you. A learning exercise for me. So good for me as well as you! But "how it happened" is much harder question. First time I have heard of precisely your problem after an update. More common is that the update has moved a few files because of a compatibility issue.
    – Gilby
    Jan 7, 2022 at 22:27
  • @Gilby I reformatted my question and posted my full solution in the question. Please update your answer. Otherwise, at the mods request I will post my own solution and have to mark it as the correct answer. Thank you.
    – RLH
    Jan 11, 2022 at 16:07
  • 1
    @RLH I don't understand your changes to the question (which have now been edited out). You said that the using chflags does not work for you (because that hidden flag is not being set). Why do you now use chflags as well as SetFile? For your problem SetFile does seem to be the answer. The bigger question for you is why did/does the invisible bit get set - but that is a different question.
    – Gilby
    Jan 11, 2022 at 21:18
4
cd Desktop
chflags nohidden *

should do the trick for all files on your desktop.

To change all files and directories you can run

chflags -R nohidden $HOME

It may unhide files which have been intentionally hidden by the OS (but this shouldn't cause any harm).

PS: man chflags has all the details.

1
  • I think that the OP is asking me or you to combine our answers into one (even though his problem seems to be the invisible bit and not the unix hidden flag). It would be easy to add your answer to the beginning of mine along with a bit about there being two potential causes. What is the etiquette for taking another person's (your) answer and pasting it into mine?
    – Gilby
    Jan 11, 2022 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .