I have an AppleScript script that runs a stress test. Part of the test is to open, save, and close certain files. Somehow, the files have picked up some "extended attributes" that prohibit the files from being saved. That causes the stress test to fail.
How do I remove the extended attributes?
Another recursive approach:
Removing a Single Attribute on a Single File
See Bavarious's answer.
To Remove All Extended Attributes On a Single File
Use
xattr
with the-c
flag to "clear" the attributes:To Remove All Extended Attributes On Many Files
To recursively remove extended attributes on all files in a directory, combine the
-c
"clear" flag with the-r
recursive flag:A Tip for Mac OS X Users
Have a long path with spaces or special characters?
Open
Terminal.app
and start typingxattr -rc
, include a trailing space, and then then drag the file or folder to theTerminal.app
window and it will automatically add the full path with proper escaping.Try using:
This takes care of recursively removing the pesky attribute everywhere.
Use the
xattr
command. You can inspect the extended attributes:and use the
-d
option to delete one extended attribute:you can also use the
-c
option to remove all extended attributes:xattr -h
will show you the command line options, and xattr has a man page.