t-nissieの日記: 【電脳】Mac OS Xでファイルとディレクトリの拡張属性xattrを再帰的にすべて消す高速なPythonスクリプト 1
ここに置いてあったやつ,ディレクトリの拡張属性が消えないというバグがあったので,最新版を再掲.
Gistに置いたので,明日からはそっちでアップデートしていきます.
行頭のタブが消えないとよいのだけど:
#!/usr/bin/env python
# delxattr.py recursively removes all extended attributes (xattr) from
# all files and directories under the current or given directory.
# Time-stamp: <2014-01-18 22:09:43 t-nissie>
# Author: Takeshi NISHIMATSU
# Example1$ delxattr.py
# Example2$ delxattr.py ../foo
# Example3$ delxattr.py ~/foo
# Example4$ delxattr.py /tmp/foo/bar
# Copying: delxattr.py is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY. You can copy, modify and
# redistribute delxattr.py, but only under the conditions described
# in the GNU General Public License (the "GPL"). For more detail,
# see http://www.gnu.org/licenses/gpl.html .
##
import sys
import os
import xattr
try:
dir = sys.argv[1]
except IndexError:
dir = "."
for dpath,dnames,fnames in os.walk(dir):
for fname in dnames+fnames:
f = os.path.join(dpath,fname)
if os.path.islink(f):
continue
xattr.xattr(f).clear()
dnames+fnamesにしないとダメだった.
fnamesだけのときはディレクトリ単体がリストの中に入らなかった.
xattr -rc /path/to/a/directory (スコア:1)
Mac OS Xのバージョンによっては
でできるみたい。ヘルプ
を見て。
love && peace && free_software
t-nissie