How can I make files hidden on Mac Os X without changing their filename?

Discussion in 'Mac OS X Server, Xserve, and Networking' started by Salteevee, Sep 9, 2011.

  1. Salteevee macrumors newbie

    Sep 9, 2011
    As I understand it, making hidden files in Mac OS x involves changing their filename to one the has '.' prefixing it via terminal. But the files I want to make hidden are an autorun.inf file and a .ico file which when placed on a usb key work to make the key icon in windows change to that of the .ico file. In windows I can make these hidden, but I want them to be hidden in both windows and mac os x.

    I think that if I changed the filenames to ones with a . prefix then they won't autorun in windows anymore making them useless but I don't want to give the disk to people with files sitting on the root level cluttering things up. At present they're invisible to windows users because the of the 'hidden' attribute but I'd like them also to be hidden for mac os x users.
  2. met24 macrumors newbie

    Sep 9, 2011
    You can use SetFile to set the Invisible attribute:

    SetFile -a V filename.txt

    That's only honoured (hey, I'm English!) by the Mac OS Finder, which appears also to honour the hidden flag set with attrib +h on Windows. That's certainly what my test just now showed: I created 4 files on a USB stick -- intending for one to be visible on both operating systems, one hidden on both, one visible on Mac OS only, and one visible on Windows only.

    I used SetFile -a V to hide the two that Mac OS shouldn't see, then moved to a Windows machine and used attrib +h to hide the two that Windows shouldn't see. Looking at it again on Mac OS, Finder only showed me the one meant to be visible on both machines -- it didn't show the one supposedly visible only on Mac OS even though GetFileInfo didn't show the invisible flag as being set.

    Terminal (or rather, ls) will always show you files whose names don't begin with a dot, even if they are (Mac OS) invisible or (Windows) hidden. ls -a will show all dot files as well. Similarly Windows Explorer can be told to show hidden files, and dir /ah will show them too.

    I reckon that's probably the best you can do for a read-write USB stick. Things are easier on a CD since hdiutil makehybrid can be told to hide files from particular filesystems -- it makes an ISO image that Windows sees as Joliet while Mac OS sees it as HFS+.

    Hope that helps!
  3. nufanec macrumors regular

    Sep 10, 2005
    chflags hidden /Volumes/Macintosh\ HD/FilePath
  4. Salteevee thread starter macrumors newbie

    Sep 9, 2011
    Thanks guys, any idea how I could go about making a drag and drop applet for the terminal commands you describe? Basically I can't find any satisfactory way without specialised equipment to automate customising 100's of USB keys so the changes to the icon must be something I can instruct people to do very simply.

    If the process can be made so that they simply have to copy the files necessary for windows on to the root level, then drag them in to a little applet to make them invisible, that would simplify everything. I take it from this there's no way to apply the hidden attribute of windows from Mac OS? That doesn't surprise me but it would be nice.

    If anything has to be done on our only windows machine in the office and it takes time out of people's day it'll probably be me doing it anyway in which case I'll just attrib +h and make the files invisible to MacOs and windows, but if I'm not around at least people can hide the files from MacOS easily if I can make that a simple drag and drop operation.
  5. Ruahrc macrumors 65816

    Jun 9, 2009
  6. Salteevee thread starter macrumors newbie

    Sep 9, 2011
    yes, except I don't think I would know how to make one. I'm not so well versed on scripting. Are any of the actions described doable with automator?

Share This Page