Lars Nielsen's Discoveries

October 27, 2012

SharePoint doesn’t overwrite a document with the same name, but creates duplicates

Filed under: Content Management,SharePoint,Troubleshooting — Lars Nielsen @ 8:27 am
Tags: ,

Here’s a strange SharePoint oddity a colleague of mine saw recently.

We found that in a certain case, SharePoint looked as if it would not overwrite a Word document when we uploaded a new version of the document, even though the uploaded document has exactly same name as the existing one.  Instead SharePoint appeared to create a fresh new copy of the document, but with exactly the same name as the existing one.  So we ended with (apparently) 2 different Word documents, both with exactly the same name, in the same document library!  Here’s what we did and what was really going on:

The document library was set up to keep only major versions of documents, no enforced check-out and no content approval.  We uploaded a document into the document library with a filename of (let’s say) Departmental Resources Statement (2011-2012) .docx

The document library had a content type that required two metadata items for Title (text) and Category (choice drop-down).  So we filled in the metadata and the document appeared in the document library as expected.

Next we edited the document outside of SharePoint and uploaded it again, making sure that the tickbox was ticked to overwrite existing documents to create a new version.  On the next screen we expected to see the metadata (Title and Category) of the existing document.  But instead we saw a blank Title textbox and the default choice for Category.  So we re-entered the title again and selected the category again, the same as before, and clicked the OK button.

Next SharePoint threw an exception screen with an error message:

The specified name is already in use. A document cannot have the same name as another document or folder in this document library or folder.  Use your browser’s Back button, and type a new name.

On looking at the documents in the document library, we could see that there were now apparently 2 copies of the document both called Departmental Resources Statement (2011-2012).docx but with different Last Modified dates.

The cause of all this was the actual filename of the original document on my colleague’s PC. The document was called (look carefully!):

Departmental Resources Statement (2011-2012) .docx

See that space character after the closing parentheses and before the dot?  When you upload the document into SharePoint, on the metadata screen it trims out whitespace either side of the filename (not the extension) so that in the SharePoint document library, this file became named:

Departmental Resources Statement (2011-2012).docx

Then when we edited the original source document and uploaded it, it was still called

Departmental Resources Statement (2011-2012) .docx

SharePoint first uploaded the file into the document library, but because of that extra space it saw the filename as different to the existing document (from which the space character has been removed) so it added it as a new document.  Then it presented the metadata screen and again SharePoint trimmed off the extra space in the name. So when we hit the OK button, SharePoint saw we were trying to give this new document the name:

Departmental Resources Statement (2011-2012).docx

And because there was already a document with that filename in the document library, it threw the error. But the 2nd copy of the document had already been uploaded at this point, so both documents were visible in the document library. On the regular document library listing in SharePoint, in proportional font, that extra space character in SharePoint is practically invisible so it looked as if both documents had the same name.

Removing the extra space character in the filename solved all this. So that was it.  Simply don’t put space characters at the beginning or end of the filename and if you do, you might see the behaviour above.  Hope this helps if someone hits the same thing one day.


Create a free website or blog at