Making files invisible

Posted:
in macOS edited January 2014
Alright, here's another random question. Is there any way in OS X to make a file invisible without putting a period in front of it? I installed Fink on my system, and I'd like the sw folder invisible, but I'm sure if I put a dot in front of it, all the command line paths will be broken. There are a few other things like this that I'd like to make invisible, too.



In OS 9, I'd just open it up in ResEdit, check the invisible box, and be on my way. Now, in OS X, I'm wondering if I can do something similar. I mean, there's all those dev, etc, bin folders that are invisible. Or is that just because they are hard-coded into the OS as invisible?

Comments

  • Reply 1 of 11
    jginsbujginsbu Posts: 135member
    Quote:

    Originally posted by bauman

    Alright, here's another random question. Is there any way in OS X to make a file invisible without putting a period in front of it?



    You might try something along the lines of how Apple hides many of the system directories in /. They do it with a .hidden file in the directory, listing which items are not to be displayed in the finder. You might try getting this to work in other places too. I did try creating a .hidden for my home directory, which didn't seem to do anything (even after restarting the Finder), but perhaps with a bit of fiddling you could get it to work.
  • Reply 2 of 11
    baumanbauman Posts: 1,248member
    Great suggestion. I did play around with it a bit, and in the / directory, I was able to add two folders (sw and Desktop) that I didn't want to show up, restarted the finder, and they were invisible.



    Then I tried it in the Home folder, but it didn't work. I wonder if something in .DS_Store (or something like it) needs to be changed in order for the finder to look for a .hidden file. Then again, they just might have it hard coded into the finder to only look for the .hidden in the root directory.



    Edit: That very well may be the case. A search for .hidden only brings up the file in the root directory (well, and the one I created in the home folder). \
  • Reply 3 of 11
    saabmp3saabmp3 Posts: 52member
    jginsbu was correct, all you need to do is add 'sw' to the .hidden file (by logging into root) and it'll disappear. I just tried it and it works like a charm, good idea.



    BEN
  • Reply 4 of 11
    baumanbauman Posts: 1,248member
    Quote:

    Originally posted by saabmp3

    jginsbu was correct, all you need to do is add 'sw' to the .hidden file (by logging into root) and it'll disappear. I just tried it and it works like a charm, good idea.



    BEN




    Erm, logging in as root? I think it's a bit safer to do "sudo chown yourusername /.hidden" and then edit it in BBEdit with the Open Hidden... command.



    After you're done, just "chown system /.hidden" Saves you from headache of .DS_Store that are owned by root.
  • Reply 5 of 11
    jginsbujginsbu Posts: 135member
    I've done just a bit of further looking into the hidden files issue in OS X, and here's a good explanation:



    "As with other Unix flavors, you can make a file invisible by prefixing its name with a ., as in /.vol. This has the effect of making it invisible in the Finder, as well as when you issue an ls without the -a option.



    Mac OS X also uses a file in the root directory (.hidden) to maintain a list of files that should be hidden from the Finder.



    Also, HFS+ (the filesystem used by Mac OS) files and directories can have a hidden attribute set using the SetFile command, as in SetFile -a V SomeFile. (The SetFile command is available in /Developer/Tools after you install the Mac OS X Developer Tools package described in the sidebar.) This setting won't take effect until you relaunch the Finder. You can log out and log in again or use the Force Quit option from the Apple menu. You can turn off the invisible bit with SetFile -a v SomeFile. See the manpage for SetFile for more details. (Note that invisible files are only invisible from the Finder; you can still see them with ls.)"

    From http://www.macdevcenter.com/lpt/a/2792



    I assume this isn't the case, but you might try seeing if /.hidden will take paths to files in other directories. In addition, TinkerTool has an option to reveal hidden files in the Finder, so they probably know how the Finder interacts with the .hidden file and if users can set up their own.
  • Reply 6 of 11
    baumanbauman Posts: 1,248member
    You are absolutely wonderful I copied the SetFile (and GetFileInfo just for fun) into the sbin folder (I'm no Unix geek. Is this where I should put it?). I then did the command you said, "SetFile -a V /file/to/make/invisible." It worked like a dream.



    Oh, and I tried using the .hidden to list files further down in a directory. Nothing happened. I assume it just doesn't recognize paths, and if it comes across a line that doesn't match a file in the root directory, it just ignores it.
  • Reply 7 of 11
    saabmp3saabmp3 Posts: 52member
    Quote:

    Originally posted by bauman

    Erm, logging in as root? I think it's a bit safer to do "sudo chown yourusername /.hidden" and then edit it in BBEdit with the Open Hidden... command.



    After you're done, just "chown system /.hidden" Saves you from headache of .DS_Store that are owned by root.






    Ok, ok, your right, I guess most people shouldn't log into root like that (aka logging into the actual user enviroment as root). I've been using *nix systems for many years now and I guess just don't really have qualms screwing around with things in there if I know what they are doing. Editing a '.hidden' file doesn't really concern me too much :-p. Don't bother warning me about it like I know tons of people will, people used to pay me to do this kind of stuff before I went off to college.



    BEN
  • Reply 8 of 11
    jginsbujginsbu Posts: 135member
    Anyone have any idea why Apple didn't make the Desktop folder hidden by default? It seems like an obvious thing to do, and would be consistent with their practice before OS X.



    The best I can figure is that it's a multiuser related concern: While having your own Desktop folder hidden eliminates potential confusion without limiting access (the files are on your Desktop after all), having other users Desktops hidden would prevent access to the files in them through the Finder. OTOH, I'm pretty sure this could be gotten around rather easily: perhaps by having the Finder check for a .hidden file for each user in ~/ in addition to the one in /. Any ideas?
  • Reply 9 of 11
    kickahakickaha Posts: 8,760member
    Actually, it's so you have access to all those files on your Desktop, even if you have umpteen gazillion windows open obscuring said Desktop.



    I've never understood why people plop files on there willy nilly then open windows over the top. *shrug*



    Now of course there's Expose's 'Show Desktop' feature, so that's a nice hack^h^h^h^hworkaround.
  • Reply 10 of 11
    baumanbauman Posts: 1,248member
    No, I didn't hide my ~/Desktop folder, I hid my /Desktop folder... for some reason, even if I do a sudo rm, it still returns. I don't even know why it's there, but with it hidden, I'm happy, and so is OS X.



    I have great appreciation for the ~/Desktop folder. For example, in Safari, you download a file to the desktop and then click the magnifying glass, and instead of moving everything around to show you your file, it opens up a window that shows your file. I think it's a great thing
  • Reply 11 of 11
    baumanbauman Posts: 1,248member
    OK, now here's an interesting twist: Does SetFile -a V work on symbolic links?



    I thought it would be a great idea to hide away all those etc, var, tmp, etc. folders on my other partition, since I don't need to see the junk of another installation of OS X. So I went through, did the sudo SetFile -a V on all the files, and restarted the Finder. All the files and folders were gone, but those that are symbolic links are still visible. I tried using the GetFileInfo command to make sure that I did it right, and sure enough, the V option was set, and capitalized.



    I don't know how to create symbolic links, so I can't test it with a symbolic link that I create, but SetFile accurately hides away aliases.



    Edit: OK. I learned how to make symbolic links with ln -s, and I tried it on an empty folder that I created. I did the SetFile -a V symlink, and guess what happened... the command followed the symbolic link and turned the original folder invisible! heheheh. So, any guesses on how to turn the link itself invisible?
Sign In or Register to comment.