2013年11月12日 星期二

How to Remove .Ds_Store Files on Mac Os X

.DS_Store (Desktop Services Store),是Apple公司的操作系統創建的一個隱藏文件,目的在於存貯資料夾的自定義屬性,例如文件們的圖標位置或者是背景色的選擇。就像 Windows上的desktop.ini。當我們從Mac OS使用過的文件夾是寫入時,可發現這些自動生成的文件。
Open Terminal.
Terminal will prompt you for a password Use your administrator account password. If you don't have a password, leave it blank.
1.防止.DS_Store 檔案產生
defaults write DSDontWriteNetworkStores true
2.刪除 delete .DS_Store
sudo find . -name ".DS_Store" -depth -exec rm {} \;

HowTo delete .DS_Store files ?

  • Open the
  • Set the root Directory from where all .DS_Store should be removed recursively
    • cd /my/directory
    • ENTER
  • Now start the command to delete them starting at your directory
    • find . -name *.DS_Store -type f -exec rm {} \;
    • ENTER
If its a large directory with many files it can take some time.
If you don’t see .DS_store files, but getting problems, then you can configure the Finder to show hidden files.

Breakdown of Terminal commands used in this document
  • sudo ls
    • sudo : Stands for 'Switch User and Do'. This causes anything typed after it to be executed from the most powerful account on the computer (Root) essentially making it so permissions and access denied error messages will not get in your way. In Mac OS X this remains in effect until you close and reopen Terminal.
    • ls : Stands for 'List' and makes Terminal list all of the files and folders in the current directory. We simply used this so we had something non-invasive trailing the sudo command.
  • cd
    • cd : Stands for 'Change Directory' and is used to navigate around the folder structure of the computer.
    • The path : Is where we want to navigate to. Some shortcuts include: ~ for the home folder of your currently logged in user and / for 'Macintosh HD' [ie. cd ~is the same as cd /Users/<your name="">]
  • rm -f <file>
    • rm : Stands for 'Remove' and is used to delete files.
    • -f : This is called a flag and is used to modify a command. In this case, it tells the rm command to force it to happen (ignore permissions, and objections). If we wanted to delete a folder we would need to use the -r flag as well which means to be recursive (i.e., delete everything inside so BE VERY CAREFUL WITH THE -r flag!).
    • The File : This is the file to be deleted.

.DS_Store cleaner for Mac OS X與Windows
壓縮時可自動清除.DS_Store 與 __MACOSX


Ratings and Recommendations by outbrain