I always get questions from my clients on whether you need to adhere to some sort of file naming convention in SharePoint. The answer is YES, in fact it is a must, if you are using metadata. It has to do with the way SharePoint treats duplicate file names. In SharePoint, the file name is the primary (unique) key that identifies the file. That means that if you try to upload another document with the same file name, it treats it as another version of the the same file and will overwrite the previous version without warning!
Let me demonstrate this to you in the example below.
- User uploads a document to the library. Note that the checkbox next to Add as a new version to existing files is checked by default
- User tags the document with some metadata
- Another (or same user) uploads the document with same file name again to that same library. Let’s pretend that it is an Agenda from another meeting. So while the file name is the same, the document itself is different. But look what happens on metadata screen. All the metadata fields are empty again and version of the document is 2.0. What is going on here?
- What happens is that it treats that 2nd document as another version of the same file. So it creates another version!!!
- Unfortunately, the file also looses all the metadata. This behavior (lost metadata) is unique to just the new MS Office file formats (.docx, .xlsx, .pptx), not the older MS Office formats (.doc, .xls, .ppt) or other file types (i.e. PDF, TXT, etc.)]
How to prevent file overwrite in SharePoint
There are few ways to prevent accidental file overwrite in SharePoint
- Uncheck the box during file upload. When you upload a document, uncheck Add as a new version to existing files check box. This has to be done manually every single time. There is no easy (out of the box way) to disable this check box globally. Once you uncheck the box and click OK, you will get an error message, prompting you to rename the uploaded file.
- Upload files using drag and drop. The file overwrite issue only occurs when you upload a file using the Upload button. If you drag and drop the file into the browser, it actually gives you a great warning message, asking you to either replace the file (upload as another version) or stop the upload. This message gives you a second chance and allows you to check into the original document and rename the file (if need be). This totally makes sense to me and I wish this sensible message was there during the regular file upload.
- Separate files into folders. I can’t believe I said that. For obvious reasons, you will only encounter the overwrite issues if you have 2 files with the same file name in the same folder. That means that if you use metadata, you have higher chances of running into “accidental overwrite” situation. With metadata, everything resides in 1 big bucket. If you use folders, the likelihood of file overwrite is minimized.
- Come up with file naming convention. If you do use metadata (I hope you do), the best way to avoid accidental overwrite is by instituting some sort of naming convention. It is very unlikely that users will remember to always uncheck that box in Step 1, so a solid naming convention is a great alternative. As far as the advice on the naming convention, it really varies from company to company. I don’t think you will ever find a standard that is one size fits all. I usually like to insert some sort of descriptive information into a file, like client or vendor name. Another technique is to insert a date into the file name (i.e. 20160624) – this helps make the document unique and is is a sure way to prevent file overwrites.