TextEdit keeps duplicating my text file and adding a strange extension

A lot of the time, when I open a file in TextEdit, such as test.txt, it will create another file test.txt.sb-d7bff531-E4qLT8 in the same directory.

Why does it do this?


Solution 1:

If you also get errors like this, it's probably the same issue I had.

The document “temp.txt” could not be opened. You don’t have permission.

To view or change permissions, select the item in the Finder and choose File > Get Info.

There were messages like this in system.log, so it could be related to Versions or sandboxing:

9/13/12 10:41:55.118 PM TextEdit[357]: NSFileVersion tried to tried to add a new generation and failed. Versioned file URL: file://localhost/Users/lauri/Notes/temp.txt, contents URL: file://localhost/Users/lauri/Notes/temp.txt.sb-de6477ff-BhVNrq, error: Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"
9/13/12 10:41:55.118 PM TextEdit[357]: NSDocument failed to preserve the old version of a document. Here's the error:
Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"
9/13/12 10:41:55.119 PM TextEdit[357]: <Document: 0x7f971d00a510>: An error occurred while attempting to preserve the backup file at file://localhost/Users/lauri/Notes/temp.txt.sb-de6477ff-BhVNrq: Error Domain=GSLibraryErrorDomain Code=1 "The operation couldn’t be completed. (GSLibraryErrorDomain error 1.)"

I ended up replacing TextEdit with TextEditPlus, and I haven't gotten those errors or extra temp files after that. It's based on a version of TextEdit that came with Lion, but it's still mostly identical to the current version.