メタデータを表示するコマンド「mdls」を見つけましたが、削除する方法がわかりません。
ファイルから「kMDItemFinderComment」、「kMDItemWhereFroms」というコメントを削除したいと思います。
これを行う方法はありますか?
メタデータを表示するコマンド「mdls」を見つけましたが、削除する方法がわかりません。
ファイルから「kMDItemFinderComment」、「kMDItemWhereFroms」というコメントを削除したいと思います。
これを行う方法はありますか?
ターミナルで利用できるxattrコマンドを探していると思います。
xattr -pr com.apple.metadata:kMDItemFinderComment /
これにより、ブートボリューム上のすべてのファイルのすべてのファインダーコメントが出力されます。削除するには、-dスイッチを使用します。
xattr -dr com.apple.metadata:kMDItemFinderComment /
一括で実行する前に、これを1つのファイルでテストする必要があります。
usage: xattr [-l] [-r] [-v] [-x] file [file ...]
xattr -p [-l] [-r] [-v] [-x] attr_name file [file ...]
xattr -w [-r] [-v] [-x] attr_name attr_value file [file ...]
xattr -d [-r] [-v] attr_name file [file ...]
The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to the string attr_value.
The fourth form (-d) deletes the xattr attr_name.
options:
-h: print this help
-r: act recursively
-l: print long format (attr_name: attr_value and hex output has offsets and
ascii representation)
-v: also print filename (automatic with -r and with multiple files)
-x: attr_value is represented as a hex string for input and output
これは次の方法で実行できます。
xattr -d com.apple.metadata:kMDItemFinderComment <file>
xattr -d com.apple.metadata:kMDItemWhereFroms <file>
私のために働くようです。
Spotlightコメントは、.DS_Storeファイルにも保存されます。Finderの情報ウィンドウにコメントを追加して実行しようとすると、コメントはFinderxattr -d com.apple.metadata:kMDItemFinderComment
に表示されますが、では表示されませんmdls -n kMDItemFinderComment
。これにより、両方が削除されます。
find . -name .DS_Store -delete
xattr -dr com.apple.metadata:kMDItemFinderComment .