Some of my Mac files are giving an error that the file maybe damaged or locked, even though I own the document and can open it.
Problem
You are trying to do something with a document you own on the Mac, but it says it is damaged or locked.
Example
You are trying to modify the document, but says you can't because the file is locked.
You look at the permissions of the document, including ownership and they give you full permission.
Cause
This is probably a resultant of some extended attributes saved onto the file that the Operating System is confusing the file as being in a locked state.
Solution
One way to fix this is the following:
- Open up Terminal for the Mac.
- Change into the directory where the document exists using 'cd <folder location' (IE: 'cd Documents/Data'. You can also press 'Tab' to try and auto complete the path, so example: 'cd Lib<Tab>' will go 'cd Library')
- Type 'ls -l'. Look for your affected document and see if there is an '@' symbol showing at the end of the first column. This indicates it has extended attributes.
- Type 'ls -l@ <file>'. This will show attributes on the file.
- Type 'xattr -d com.apple.ResourceFork <file>' - This is to remove the resource attribute from the file which may be locking the file.
- Test working with the file to see if it works properly.
Similar error message but can not open the file
If you get the same message, but are unable to open the file.
You might have additional issues.
One of the main causes of this error message, but with files that cannot be opened and cannot be resolved by the above instructions is file misnaming.
If you modify a file's extension without actually converting the file to the new format, for example, saving a .png file as .jpg, do not be surprised when your file does not open.
Additionally special characters such as the following: .!@#$%^&*() can be treated as commands by your computer and also cause a file to be opened incorrectly. i.e. saving a file as image.png.jpg will just confuse the computer.
- Look at the original source file. Then make sure the file that is giving you issues, does not have special characters or a different file extension.
- If you are deliberately trying to save a file in a different format, try the Save as command. You may need to use a file conversion program. Renaming a file's extension will not cause a file to convert to the new format.
- If your file does contain special characters or an incorrect extension, try renaming the file.
- If issues persist, once the file is renamed, Open up Terminal for the Mac.
- Change into the directory where the document exists using 'cd <folder location' (IE: 'cd Documents/Data'. You can also press 'Tab' to try and auto complete the path, so example: 'cd Lib<Tab>' will go 'cd Library')
- Type 'ls -al'. Look for your affected document and see if there is a ._ <file> where <file> is your file name. These are hidden files that tell a mac how to open a file. Be warned that modifying or removing this file may wipe any preferences saved to said file, microsoft "last used settings" are very vulnerable to being wiped.
- Type rm ._ <file>
- Reopen the file normally. A new ._ <file> will be created automatically by the mac if one does not already exist.
Related articles