View All Blog Posts

Re-writing File Paths

3 November 2014

Requires : Data Sync Release Version 3.0.888 or higher.

The Data Sync File System provider now allows for the re-writing of Filenames and Paths which is handy if you want to clean up some directories prior to importing into SharePoint. You can even use it to remove all the directories to create a list of files.

Start by configuring a simple project that maps the source folder to a target folder.


This source directory contains a few folders and five documents.

Source Directory

To remove all the folders we simply map the Filename to FullFilename and remove the Path and FileName from the schema map.

Schema Map

This produces a directory containing the files with no directories.


Now imagine we want to use the path with the filename combined we can easily do this with a Calculated Column to create a new filename. For example below we use the FORMAT function to concatenate the Path and Filename to produce a new filename. Mapping this to FullFilename re-writes all the filenames on the target.

Calculated Column

Producing the following result.


Then with a dynamic column you could write a function to calculate a path based on when the file was last modified allowing you to group files into directories by date.

Here we create a new path for the file based on the last time the file was written to and put then into folders grouped by month.

Dynamic Columns

The schema map is slightly different since we want to map Filename and Path this time.


This time we get folders named as Dates and the files that we're modified placed under them.


As you can see using the FileSystem provider to clean up your directories prior to importing into SharePoint is now quick and easy with a little bit of code you can almost do anything.

| |
