我想你所遇到的問題是,你的文件實際上並沒有對他們的標籤 - 他們可能只是有標籤。
雖然小牛隊中的新標籤系統是通過將標籤顯示爲標籤來構建舊標籤系統,但在小牛隊之前的Mac OS X版本中標記爲黃色的文件實際上可能沒有適當的標籤。他們只有老牌的標籤,小牛表現爲標籤。如果文件上的標籤是黃色和藍色的標籤,那麼這些標籤可能就是標籤。這可能是你試圖用xattr刪除它們時看到錯誤的原因。
因此,如果您的文件只有標籤,刪除標籤的方式與您仍在運行Mountain Lion的方式相同。您要求Finder將文件的標籤索引設置爲0.
此AppleScript會要求您選擇一個文件夾,然後循環該文件夾中的所有文件,並且如果文件上有標籤,則標籤已移除。
tell application "Finder"
activate
set theFolder to (choose folder with prompt "Choose a folder to remove labels from the files within:")
set theFiles to every file of theFolder
repeat with theFile in theFiles
if the label index of theFile is not equal to 0 then
set the label index of theFile to 0
end if
end repeat
open theFolder
end tell
需要明確的是:上述的AppleScript只刪除已如果您手動標記在小牛的文件通過開放Mac OS X的,因爲之前存在的7個標準標記/標籤顏色獲取的信息窗口,鍵入項目名稱或類似的東西作爲標籤,那麼該標籤將不得不通過shell腳本刪除,如上面adayzdone的回覆中所述。
使用'mdls〜/ Desktop/Folder/test.rtf'時,可以看到'kMDItemUserTags'屬性,但是當我嘗試使用'xattr -rd com.apple.metadata ...'時,出現錯誤說'沒有這樣的xattr:com.apple.metatdata:_kMDItemUserTags' – Hacker
你能發佈一個示例文件嗎? – adayzdone