Hide any File or Folder by Making it Invisible to the Mac OS X Finder with setfile

Aug 11, 2009 - 18 Comments

Terminal in OS XIf you ever want to hide a file or folder, you can quickly make it invisible with a command line utility called setfile. This is a really cool tip that should be particularly useful to those who share their mac with other people.


I use this trick all the time to hide my personal files before my roommate uses my computer, and it’s easy to do if you know how. At the same time, it’s unlikely that another user will even think to look in a directory via the Terminal to find the file.

Make a file or folder invisible in Mac OS X Finder

You’ll need to open Terminal to get started, then just use the following syntax:

setfile -a V testfile.txt

Poof! Like magic, the file or folder is no longer visible via the Finder GUI, but don’t worry your files are still there and you can find them via the command line and will show with an ls command. If you want to make your files and folders visible again, use this command:

Make a file or folder visible again in Mac OS X Finder

setfile -a v testfile.txt

Now the file/folder will be visible again to the Finder, cool huh?

Note: setfile is a command line utility included in Apple’s Developer Tools, which is a highly recommended optional install included on any Mac OS X install/restore CD/DVD and also available as a rather large download from Apple’s Developer center. If you want to use setfile without installing Developer Tools you can try this trick on macosxhints.com. Thanks for pointing this out Albert!

.

Related articles:

Posted by: Paul Horowitz in Command Line, Security, Tips & Tricks, Utilities

18 Comments

» Comments RSS Feed

  1. Harpiest says:

    my problem is bit different
    i’ve dual partition with windows
    i’ve hidden some files in windows
    n i want to upload it from mac
    i cant find it on “Choose Files” dialogue tab
    and its doesn’t have a ” . ” on initial file name but it still hidden
    how to make it become visible??

  2. foo says:

    Rename a file/folder with a “.” as first character.

    Finder does not allow this, so with the Bash:

    mv foo.txt .foo.txt

  3. […] which allows you to set any directory or file as invisible, you can read more about hiding files and folders with setfile in Mac OS X, but the limitations on visibility are practically identical to the above technique: file is […]

  4. James S. says:

    Nice little trick! If one uses this on a folder, one can still access it in Finder using the “goto” command (Shift-Cmd-G) and typing the path.

  5. Nevil says:

    I have installed Snow Leopard and have tried typing this SetFile command. It is not an actual command as far as I can tell.

  6. Bobby says:

    If I don’t want to share certain files, I use Disk Utility to create an encrypted disk image, then, because no-one likes stuff being kept from them (“I thought you trusted me etc etc?”), I copy-paste a folder icon onto the dmg and give it a system-file-esque sort of name with the extension hidden.

    It ends up effectively being a password-protected (yet totally average looking) folder, and there’s not much chance of accidentally leaving it available to others (it clearly mounts on the desktop with the drive icon and only needs ejecting when you’re done with it)

  7. Benoit Garbinato says:

    It’s SetFile, not setfile…

  8. Benoit Garbinato says:

    It’s SetFile, not setfile…

  9. Benoit Garbinato says:

    It’s SetFile, not setfile…

  10. Benoit Garbinato says:

    It’s SetFile, not setfile…

  11. Chris B says:

    Wonders if this command can be put into an AppleScript, thus more easily called when one wants to hide/show a certain folder. (And name it something that doesn’t reveal it’s true operation).

    An even better way to hide folders from roommates is to set up a ‘Guest’ account so others can use your computer without prying into your files. Simply logging out of your account or set up a screen saver password seems easier than pulling up the terminal, etc.

  12. ‘setfile’ is an utility from Apple’s developer’s kit and is not included in default Leopard install.

  13. Albert says:

    ‘setfile’ is not a Leopard command, is it?

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site