Skip to main content

OneDrive - Prepare your data for OneDrive on macOS

Microsoft has introduced Known Folder Move (KFM) for OneDrive which allows users to automatically backup their Desktop and Documents folders to OneDrive. For Secure Computing devices, KFM is enabled and configured automatically.

Due to differences between Apple’s and Microsoft’s file system, some users may have files that are incompatible with OneDrive. Before they can be uploaded, some files may need to be renamed to remove characters that are acceptable on an Apple file system but not on a Microsoft file system or have their file path shortened. Disallowed characters include: (" * : < > ? / \ |) as well as any leading spaces or trailing spaces. Learn more about disallowed characters on Microsoft's website. 

OIT offers several scripts that users can run to clean up these illegal characters and identify files that need to have their name shortened. It is highly recommended to prepare your data before setting up your new Secure Computing device to ensure a smoother experience.

Download and run script

Download the scripts and manually run them before migrating your data. When running them you must specify the folder you want the script to run on. For example:

sudo ./ “/Users/<username>/Desktop”

Find illegal characters

You can proactively look for files with illegal characters and address them before KFM is enabled to reduce the impact to your workflow. This script will scan the specified folder for these types of files and generate a .log on your Desktop.

Find long file paths

Files whose file path is too long for OneDrive will not be able to be sync’d to OneDrive and backed up. These files must be manually renamed or moved to shorten their file path. This script will scan the specified folder for these types of files and generate a .log on your Desktop.

Fix file names

When OneDrive Known Folder Move is enabled, if there are files or directories with illegal characters, OneDrive will alert the user that they exist, and the data won’t be sync'd until the illegal characters are removed. This script will scan the specified folder to rename these files and replace any illegal characters with an underscore.

  1. The script will scan the target folder and creates a list of directories and a list of files that have illegal characters.
  2. The script will pass over the list of directories first and then when complete re-run on the list of files. 
    • During each pass the script will copy the old file/directory to a backup located in your home folder
  3. When all files/directories have been renamed you will receive an alert letting you know the fixes have been completed and where to find the backup. 
  4. If you have many files that need to be renamed, it is recommended you rescan for any illegal characters to see if you need to make a second pass with this script.

Access scripts using Self Service

If your machine is already a Secure Computing device these scripts are also available in Self Service:

  1. Open Self Service from your Applications folder.
  2. Search for OneDrive in the Self Service search bar.
  3. Run one of the many tools for identifying and/or fixing files (pictured below).