Change Your Ways – Stop Using Folders in SharePoint Libraries

[This is a quick post that will be updated with more information later]

One indicator of how how mature an organization is with their SharePoint management and usage is if folders are often/always used in document libraries. This is a practice learned when using file shares and then migrated into SharePoint sites either by simply copying data straight from those shares or by users not knowing of a better way.

Thankfully, there is a better way! Using SharePoint columns, we can offer the same document organization but with added benefits of filtering, grouping, and sorting all documents in a library. Let’s look at an example of how this can be a benefit for you and your file organization. Let’s say I have my documents organized in folders in the following way:

Folders Hierarchy
Sample File Share Folder Structure

In the above example, the Shared Documents library is organized with two main folders: Clients and Suppliers. Under each folder, there are files and more folders – in this example the folders are Company names. As it happens, the same company, Company 1, is a Client and a Supplier. How would I find all contracts for the year 2015? I would have to look within each Company folder within both Clients and Suppliers. What if I wanted to see all contracts for Company 1? I would need to navigate down through Clients -> Company 1 -> Contracts -> 2015, go back and look in the 2016 folder, then go to to the Suppliers -> Company 1 -> Contracts -> 2015 folder, then go back and look in the 2016 folder. Hopefully, you can see this folder structure limits my ability to group documents in different ways without modifying the folder structure. A better way to organize the document library could be to put all the documents in the root of the library and then create metadata columns allowing the user to select Company Name, Type of Document, Year, etc.

Let’s look at a simple example of what a reorganization would look like with another group of documents.

SharePoint Document Library with Folders
SharePoint Document Library with Folders

This document library has documents in the root and within folders. For this simple example (using IE 11 and a Windows 10 computer), there is only one level of folder hierarchy, but there could be many more. If we create one library metadata column called Document Type, we can take the files out of the folders and assign the same data as the folder names.

First step in this process is to create the library column. Open the document library in Internet Explorer 11 and click the Settings button within the Library ribbon.

Document Library Settings Button
Document Library Settings Button

Next click the Create column link in the middle of the Library settings page.

Document Library Columns
Document Library Columns

Name the column Document Type and select the type to be Choice. Give the column a description if  you want, and then in the choices box type each folder name (in order that you want them to appear) on its own line. Click the OK button to save your column.

Column Choice Box
Column Choice Box

Go back to your Document Library using the breadcrumb navigation at the top of the page.

You should now see the new column to the right of your document list. The next step is to assign the Document Type to the documents. We will do this step before removing the documents from the folders so we can easily see what choice to make on each document. One way to do this is to use the Quick Edit view of the library.

The files in the root of the library will not get a Document Type in this example because they were not in a folder. You can easily go back and add an option for those if you would like – you would edit the Document Type column in the library settings.

Step 1: open one of the folders – first up in this example is Calendars.

Step 2: select the Quick Edit button on the Library ribbon.

Quick Edit on Library Ribbon
Quick Edit on Library Ribbon

Step 3: for each file, select Calendars in the Document Type column. Remember: Copy and Paste is your friend!

Step 4: once all the documents have been updated, click the View button in the Library ribbon.

Step 5: using the breadcrumb navigation, go back to the root of your document library (select the Browse link in the ribbon to see the breadcrumbs).

Repeat the steps until you have all the documents updated with the proper Document Type.

Open the document library in Explorer view by selecting the Open with Explorer button on the Library ribbon.

Open With Explorer
Open With Explorer

Within Explorer, go into each folder, and cut (using the Ctrl+x shortcut) the document. Navigate back to the root of the library in Explorer and paste the documents (using the Ctrl+v shortcut). Once that is complete, you can close the Explorer window. Reload the document library in the browser and you should now see all your documents listed with the right Document Type. Last step to the reorganization is to delete the folders!

Now you will be able to sort, filter, and group your documents more effectively. Protip: you can create shortcuts to your sorted, filtered, and grouped views. This will give your users a quick link to view that can answer the questions asked in the first example at the beginning of this post.

Files organized using folders within SharePoint document libraries is not only inefficient, but it can also cause technical issues that I will possibly cover in the future.

Renaming a document – ”The Specified name is already in use”

A SharePoint document library in some ways acts similar to a folder when storing documents on your local computer. For example, you can’t have two documents with the same name within a document library (or folder, if you are using folders). If you try to rename a document and give it the same name as another document in the library, you will be given this wonderful error (in SharePoint 2007):
error
[Server Error in ‘/’ Application. The specified name is already in use. A document cannot have the same name as another document or folder in this library or folder. Click your browser’s Back button, and type a new name.]


This makes perfect sense, unless the “existing file” really isn’t there. I recently ran into an issue where a user tried multiple times to upload a document (PEBKAC) and finally, they received the error that they couldn’t add the document with the current name because it already existed. Somehow, the document they were uploading and checking-in was removed from the database, but SharePoint thought it was still there. So, they couldn’t upload a document or rename a document with that same name.
When I tried to upload a document to the library, I received the error below that says the document (which wasn’t really there) was checked-out to the user that was uploading the document from before.




[Error. The {filename} is checked out or locked for editing by {username}]
Again, since the document really wasn’t there, it was a bit frustrating, but this last error did give me insight into how to resolve the issue. The fix in this case was simple enough. After opening the document library’s settings, I opened the Manage checked out files page (selected from the Permissions and Management column).

error1

Since SharePoint did believe the document was still there, I am given the wonderful opportunity to “Take Ownership” of the checked-out document.

error2

After selecting the checkbox next to the document and clicking the Take Ownership of Selection button, the document was then checked-out to me. I then was able to upload a document with the same name (the library had versioning turned on, so I selected for it to add another version).