Skip to main content
< All Articles

How to automatically tag files with metadata based on folders in SharePoint

Posted on September 4, 2019
SharePoint

This is very unusual – I have used the “F” word and metadata in the same sentence. But that is precisely what this post is all about. Despite being a staunch supporter of metadata, I realize that many users might not necessarily get buy-in with metadata right away. If that is the case – this trick below might appease both the folder conservatives and metadata liberals. And to help us out, we will use a feature called Column Default Value Settings. Let me explain to you what it is and how to use this feature to tag files with metadata based on folders.

What are Column Default Value Settings?

Column Default Value Settings is a feature of a document library that allows you to associate (map) folders with particular metadata columns. Once configured, documents dropped into folders will get the respective metadata assigned to the folder.

How to set up Column Default Value Settings?

Step 1: Create your folder hierarchy

The first step in the process is to create your folder hierarchy. I assume your IQ is high enough to know how to create new folders in SharePoint so that I won’t be covering those steps here. Go ahead and create folders and subfolders, don’t go crazy with deep folder hierarchies – try to keep it as flat as possible. Later on, we will need to map these folders to metadata, so the more folders you create, the more set up it is for you. In my case, I created two levels of folders, top-level with Client Names (i.e., Facebook, Google, Microsoft) and subfolders underneath each client folder for different types of documents (i.e., Invoices, Quotes, Contracts).

Autotagfoldersmetadata1

Top Level folders (Level 1)

Autotagfoldersmetadata2

Subfolders (Level 2)

Step 2: Create your metadata columns

Now it is time to create metadata columns. To do this:

  1. Click Add column, select Choice Autotagfoldersmetadata3
  2. Fill in the column name, then drop-down choices, hit Save Autotagfoldersmetadata4
  3. Repeat for all the metadata columns you plan to have in your library. In my case, I created two columns: Client Name (with a drop-down for client name) and Document Type (with a drop-down for document types).

Step 3: Map folders with metadata using Column Default Value Settings feature

This is where the fun begins. Now it is time to map folders to metadata. To do this:

  1. Navigate to your Library Settings (Gear Icon > Library Settings) Autotagfoldersmetadata5
  2. On the Library Settings page, choose Column Default Value Settings tag files with metadata based on folders
  3. You will be presented with a screen that looks like one below. On the left side, you have your folder hierarchy, and in the middle, you have all your custom metadata columns. tag files with metadata based on folders
  4. So the way mapping works, you first click on a particular folder on the left that you want to map. Then, in the middle, choose the column you want to specify a value for. Next, select Use this default value radio button and type in the same choice text that you have listed in your drop-down choice columns above. I know, it is a bit odd that you need to type in text and not choose the choice from the drop-down. Make sure to spell it exactly like it is in your column. For example, in my case, I want all documents dropped into Facebook > Contracts folder to be mapped against Client Name = Facebook and Document Type = Contract. Autotagfoldersmetadata8
  5. And repeating for another column Autotagfoldersmetadata9
  6. Once you configure a particular subfolder, you will notice a green gear wheel appearing over it on the left-hand-side – that means the folder has been mapped to some metadata. So you can now move to the next folder and map it too. Autotagfoldersmetadata10
  7. Repeat the above exercise for all the folders you have (I know, sounds like fun!)

Step 4: Upload or drag and drop files into the library

Now it is time to check how this works. Go ahead and upload or drag and drop files into the folders. You will notice that they are now auto-tagged based on the folder they are uploaded into!

tag files with metadata based on folders

Step 5: Create “No Folders” view

So we just appeased the folder conservatives. There is no tagging whatsoever, all they have to do is upload files just like they did for the last 20 years. But what about us, metadata liberals? We don’t want to see those pesky folders in our view, we love metadata and wish to sort and group and folder by all those columns we have! No problem at all. This is where custom views become handy. And the trick here would be to hide (suppress) folders altogether. I published a post on how to do this previously, so check it out for detailed instructions. Once completed, you will end up with a “folder-less” library that allows you to sort/group and filter based on metadata that got auto-populated for you. Nice!

Autotagfoldersmetadata12

Limitations

Before you say “Greg, what you just showed me here is @#$% awesome,” I want you to be aware of a few significant limitations which might make you say “@#$%” word for a different reason.

You have to type in the default values

If you recall in Step 3 above, you had to type in the Text value of your metadata, even though it was a drop-down (Choice) column. It might be a bit annoying and overwhelming, especially if you have a long list of drop-down choices and don’t think of yourself as a right candidate for a spelling bee competition. If you do provide a choice that does not exist in the drop-down or misspell it – it will let you know, which is nice!

Autotagfoldersmetadata13

That said, if you defined your metadata in the Term Store (managed metadata), the behavior is different, and you will get a list from the Term Store to choose from! Another reason for you to use the mighty Term Store!

Autotagfoldersmetadata15

Auto-tagging does not work with Move or Copy commands

This is a big one, in my opinion. Say, you uploaded the docs to a folder, thanks to Column Default Value Settings, they got some metadata tags assigned. Now, if you move or copy the document to another mapped folder, the metadata will not adjust accordingly. The old metadata values will remain assigned, consistent with the behavior of a Move/Copy command.

Autotagfoldersmetadata14a

Auto-tagging does not work for files already residing in folders

Likewise, if you already had files in folders and then went through the pain of mapping them all to metadata using the instructions above, those files will be ignored and not tagged. :cry:

Auto-tagging does not work with site templates

In case you use Column Default Value Settings on a project site that you think of replicating using Site Templates, do not bother! I learned the hard way at one point, but those do not work/replicate with Site Templates. Reference this post to learn more about the issue.

Too much overhead

Honestly, I do not like to use Column Default Value Settings much. Too much maintenance, in my opinion. You have to create folders, create metadata, views, then also maintain proper mappings between the two. Every time someone creates a new folder or metadata value – someone will need to create a new mapping. But, this option does the job and become handy if you have a disciplined approach with folders and metadata in your organization.

About Me

I’m Greg Zelfond, a U.S. based SharePoint consultant, and I provide affordable out-of-the-box SharePoint consulting, training, and configuration assistance to small and medium-sized businesses all over the world.

Need help?