6

Problem: because of an unkown reason all my desktop files and folders were hidden. i managed do unhide all folders, but i can't unhide the files

i tried to unhide the files via terminal chflags nohidden filename but it doesn't work. i also checked if the hidden flag is placed, but there is no hidden flag on the files (but they aren't visible). here is the output via terminalcommand ls -lo:

-rw-r--r--@ 1 username 13669 19 Aug 11:54 filename.txt

i also tried an app called InvisibliX (which isn't under development anymore), with no success and of course i used the searching function, which lead me to this: How to unhide files on Mac? with no further success

I'm thankful for every hint you may have for me!

Some additional information regarding the OS: Mac OS X Catalina 10.15.6

9
  • 2
    So you did run chflags nohidden filename.txt and it didn't work?
    – nohillside
    Commented Aug 31, 2020 at 9:25
  • yes, i tried the command. i also checked if chflags hidden filename.txtsets a flag (i checked via ls -lo but there was no change
    – schwing
    Commented Aug 31, 2020 at 10:13
  • 1
    Your title & question body say you used unhide, which is not a valid command. Could you clarify which you in fact used. Does sudo make any difference? [as the files show only owner has permissions to write] Can you see the files if you set Finder to show invisibles Cmd/Shift/. stop/period? Do you see any error message?
    – Tetsujin
    Commented Aug 31, 2020 at 10:35
  • Long shot, but you might also try xattr -d com.apple.FinderInfo [directory] Commented Aug 31, 2020 at 11:25
  • @Tetsujin: you were right, i had written de command wrong (but only in the text here, not when i was trying to execute the command in the terminal. i made sure to not execute an invalid command. i have corrected the command in the text above (it's nohiddeninstead of unhide. an yes, i can see the files if i toggle the view setting via Cmd/Shift/. No error messages
    – schwing
    Commented Aug 31, 2020 at 13:53

5 Answers 5

13

Once I copied files via terminal from an iPod to a Mac and somehow they appeared hidden, chflags nohidden <filename> did not work, neither the same command with different option flags. Finally, I found this answer which worked fine. So:

  1. xattr -d com.apple.FinderInfo <filename>
  2. chflags nohidden <filename>
  3. killall Finder (just in case)

I did it using * so I did not have to go one by one. Hope it helps,

3

I answered the same question and OP reported that the files got unhidden at first but got hidden later on. Looks like a bug to me.


It seems you need a recursive flag.

chflags -R nohidden ~/Desktop/folder

Then kill Finder to restart it.

killall Finder
4
  • i tried this on the files, but it didn't work. i also checked the flag via ls -lo after restarting finder, but there where no changes on the file
    – schwing
    Commented Aug 31, 2020 at 13:55
  • @schwing See updated answer
    – anki
    Commented Aug 31, 2020 at 14:05
  • that's exactly the same issue on my mac! i tried the solution procedure, but it doesn't work on files, only on folders. is there maybe a workaround, to copy files with the right (nohidden) flag?
    – schwing
    Commented Aug 31, 2020 at 14:25
  • sorry I don't know..
    – anki
    Commented Oct 1, 2020 at 7:21
1

If it does help, I found what I believe would be a bug. I tried to use recursive mode to unhide files within root and subfolders. As long as I would use only the path to Root folder (Documents) the terminal console output was; No such file or directory

sudo chlfags - R nohidden /Users/user/Documents/

When I copied whole path to the file (use Command+shift+[.] to show hidden files first in Finder), hid or unhid a file within Documents folder, I was also able to just remove the file name from the path and then successfully execute Recursive action to hide/unhide all files and folders within Documents. Is this does look and feel like a bug to me.

Workaround:

chflags - R nohidden  /Users/user/Documents/filename.txt

the file was then visible.

Next step, remove the file name from the path and repeat command, to either hide or unhide.

chflags - R nohidden  /Users/user/Documents/

No need to kill Finder to confirm, just move between folder up or down to refresh the window. It worked for me on Big Sur Mac OS.

1

There seems to be a bug or undocumented behavior (at least in macOS Sequoia) where you can't unhide a file if it is inside of a hidden folder in iCloud Drive (this does not happen outside of iCloud Drive):

So, assuming you have /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt:

You can do:

chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory
chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt

And the folder AND file will be hidden. BUT if you then try to unhide just the file:

chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt

It just doesn't work, even if you restart Finder or the whole device, the file stays hidden.

For some reason, you have to unhide the folder and file:

chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory
chflags nohidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory/SomeFile.txt

Wait a couple of seconds (presumably for the change to be synced?), and then you can hide just the folder:

chflags hidden /Users/John/Library/Mobile\ Documents/com~apple~CloudDocs/SomeDirectory
2
  • Welcome to Ask Different. Your answer might be more relevant to the OP if you can demonstrate that the bug and fix you mention also applies outside of the iCloud infrastructure. macOS goes to great lengths to protect and slightly obfuscate the contents of the Mobile Documents folder, and it might be the case that you are describing an undocumented behaviour rather than a bug. The OP's question does not mention iCloud. Commented Nov 1 at 20:51
  • I have edited the answer to clarify that this might also be undocumented behavior that happens ONLY within iCloud Drive. Although OP does not specifically mention iCloud, the Documents folder is usually automatically synced so this could have been the root cause.
    – ziron321
    Commented Nov 2 at 23:26
0

Maybe you didn't use chflags hidden instead, setfile -a V.

1
  • based on /usr/bin/getfileinfo filename|folder output in the Terminal, chflags hidden|nohidden and setfile toggle the same v|V attribute-letter flag. Also, hidden|nohidden is more readable and less vulnerable to lower|upper casing a single letter. Commented May 29, 2021 at 3:32

You must log in to answer this question.

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