Creating SharePoint Folders from a File Directory Structure

This guide will cover how to add documents to a SharePoint Document Library whilst simultaneously adding these files to their corresponding folders by replicating your file system structure.

You can add files to pre-existing folders in SharePoint. Follow the same instructions as either of the methods below and so long as the name of the folders match, the file/s will be added to that folder without creating a new one.

If you do not want your files to be added in a folder, then map the FileName to the URL Path of SharePoint and the files will just be added to your document library.


Before we start going through this guide please make sure that you have all the data you require. We assume you have a directory of files, an excel spreadsheet containing the metadata for the files to be added, and a Document Library in SharePoint with the metadata columns created.

Note: We are using an excel spreadsheet for our metadata however you can use other sources such as SQL Tables, XML and CSVs.

Connect to the File Directory

To configure this project we first need to connect to our source. In this example it is the file directory on our machine.

Click on Connect Datasource in the Datasource A window and choose the File System > Files provider. Locate the parent folder that contains the folders and documents you want to add by clicking on the ellipsis (...) in the Path field. Once you have done so, click Connect to load the data source.

Connect to File System

Connect to the Document Library

Our Document Library is currently empty, with the columns ready for the metadata to be added.

Empty Document Library

Now we need to connect the target to our document library in SharePoint. As we are using SharePoint online in this example, choose the SharePoint Online Provider from the connection menu. Enter the site URL and your credentials.

Connect to SharePoint

You will then be able to choose the document Library from the drop down menu in the ListName field. In this example our document library is Document Library Test.

Select Documentation Library

Once you have done this click Connect & Create Library Connection to save your connection to the connection library. Doing this opens up the connection library window where you are asked to type in a name for your connection. Click OK once you have typed in a title.

Choice to create and save connection

Data Sync's automatic mapping rule system will prompt you to select a rule to apply, press Apply to apply this rule.

Data Sync Automatic Mapping Rule

If you need to re-run the mapping rule you can click on the Apply Mapping Rule button in the toolbar menu.

Now at this point, Data Sync is configured to import the documents to SharePoint. However, as we want to add the metadata we have one more step to go.

Create the Lookup to the Metadata

Select the FullFileName column in Data Source A and press the Add Lookup button in the data source toolbar to create a Lookup.

Add Lookup

This will open up the connection window. Find and select the Excel Provider (OpenXML Excel Spreadsheet) and locate the excel spreadsheet you wish to be used in your lookup by clicking on the ellipsis (...) in the FileName field. In this case it is our metadata document.

Connect to Excel

Now we need to configure the lookup. For this example choose FileName as the target column. Select FileName from the drop down menu so that Data Sync matches based on the filename in the Excel file.

Configure Lookup

Configure the Schema Map

Add the meta data columns to the schema map and map these to their corresponding columns in SharePoint. Our schema map is configured like this:

Schema Map Configuration

Run the Compare and Sync

We can now run the comparison by clicking Compare A -> B.

Data Compare

We can see that we have 5 new records to be added to our document library.

Compare Results

Press Synchronise and then Start to begin the sync.

Once this has successfully run, if we open our document library we can see that the folders have all been created and the files with their meta data added to the corresponding folders.

Folders Created

Files in Folders

Moving a File to another Folder

If you need to change a file's location after synchronising to your document library, then follow these steps to make sure it all runs smoothly.

For this example we are going to move the document file4.docx from Folder 3 to Folder 4. The screen-capture below shows the file currently residing in Folder 3 in SharePoint.

Files in Folders

Move the File

Move the file in your file directory and make sure to update your metadata document to include this folder change.

Run the Compare

Run the comparison by clicking Compare A -> B. You will now see the results showing that there is a file to be deleted and a file to be added.


Results Additions

Results Deletions

By default delete is disabled, however if you do wish to enable deletes go to the connection properties in your target column and scroll to EnableDelete change this from False to True. Now go back to your comparison results and check the checkbox next to the delete.

Enable Delete

Run the Sync

Run the Sync to apply the changes.

If we now go to our document library we can see that the file has been deleted from Folder 3 and is now visible in Folder 4.

Results - Folder 3

Results - Folder 4

Can't find the answers you're looking for? Contact our support team and we'll personally get back to you as quickly as we can.