setfile 
ATTRIB for OS X!
 



I don't know if anyone's noticed, but when you install the apple developer tools, as well as the usual applications, examples, documentation, etc, there are some cute CLI tools, that is; command line interface tools, or in other words.. tools of the 
terminal! If you're scared of the terminal for some reason, this might be a great opportunity to face your fears. You can't do much harm altering simple file attributes. *snigger*

The one we want is in /Developer/Tools. Do this in the terminal..

cd /Developer/Tools

"cd" is change directory. Now you are in that folder, you can run them with the --h switch, like this..

RezWack --h

and get some useful information about what each of the tools actually does. Many are purely for developers, but some are more generally useful, like the wonderful 
SetFile. The best way I can think to describe it like attrib for OS X, and if you've never used DOS you won't have a clue what that is either! anyway..

setfile: a swiss-army-knife for file attributes

SetFile is so damned handy I renamed it to "setfile" (typing caps in the terminal just feels wrong) and put it into my PATH (specifically, in /usr/local/bin, though that probably won't be in your path unless you are the kind that installs 3rd party unix binaries. If you want info on how to change your path, grab the "darkstat for OSX" distribution for more info, (darkstat also lives in usr/local/bin which is an excellent place to keep all your own wee tools) If you don't have the dev tools installed, you can download a copy of setfile here.

As a work-around for folks who don't have /usr/local/bin on there system and don't want to mess about with PATH statements, you could do a very nasty thing (this is evil) and drop it into /usr/sbin which should already be in your path, like this:

  1. unzip setfile.gz (stuffit expander is good)
  2. drop it on your desktop, and
  3. do this in the terminal..
sudo mv ~/Desktop/setfile /usr/sbin/setfile
sudo chmod +x /usr/sbin/setfile

Once you have it installed in your PATH (the chmod +x command makes it executable), type setfile in the terminal (you might need to open a fresh terminal window), and you'll see this..

setfile [option...] file...

  -a attributes # attributes (lowercase = 0, uppercase = 1)* 
  -c creator # file creator 
  -d date # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])* 
  -m date # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])* 
  -t type # file type 


  Note: Period (.) represents the current date and time. 
  Note: [yy]yy < 100 assumes 20th century, e.g. 19yy 
  Note: The following attributes may be used with the -a option: 
  A Alias file 
  V Invisible* 
  B Bundle 
  S System (name locked) 
  T Stationary 
  C Custom icon* 
  L Locked 
  I Inited* 
  N No INIT resources 
  M Shared (can run multiple times) 
  E Hidden extension* 
  D Desktop* 

Note: Options/attributes marked with an asterisk (*) are allowed with folders


or in english..

 

setfile -a V somefile.jpg

would make somefile.jpg . . .
 invisible!

In the Terminal, type..

setfile -a V   <-- there's a space at the end of that!

then simply drag somefile.jpg onto the terminal. The filename, with full path, is pasted into place! 
Oh Macness!!! 

Which answers the long-standing "How do I make something invisible without using 3rd party apps?" 

 

 

程式的輔助說明(或英文)有看沒有懂得請看這邊!!

$ setfile -a V somefile.jpg

上面這行命令,會讓 somefile.jpg . . . 消失無蹤了!

打開 Terminal 應用程式,鍵入以下命令。。。

$ setfile -a V  <-- 在命令結尾(即『V』字母)後面空一個空格(加一個空白符號,即游標停住的地方)

現在只要拖著 somefile.jpg 丟進 terminal 後的空白符號上,檔案名稱會隨著完整路徑,貼在那個空白符號位置上(記得按『Enter』)!喔 真不愧是麥金塔!!!

上面的方法就回答了長期以來,存在已久的問題:『我要如何在不使用第三方的應用軟體之下隱藏某些文件?』

註:要將已經『隱藏』的文件變回來,請執行以下命令:

$ setfile -a v somefile.jpg

 

arrow
arrow
    全站熱搜

    Bluelove1968 發表在 痞客邦 留言(0) 人氣()