Forum Discussion

AKIMF's avatar
AKIMF
Iron Contributor
Dec 07, 2016

Shorten local OneDrive path to avoid windows path length limitations

When we set up OneDrive for business, we keep the same local path on every pc:

c:\OneDrive

Since our company name is quite long, every synced SharePoint will be somthing like:

c:\OneDrive\veryveryverylongcompanyname\project_xxxx

 

Currently we are moving some local network drive folders to SharePoint or Outlook Groups and are facing path length conflicts due to the long base path. Any way to shorten your company name without changing it globally?

 

16 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    As I understand it, you want to shorten the local path without changing your organization's name globally. Here are some solutions that might help you achieve this.

     

    Recommended Solution: Group Policy / Intune (The Supported Method)

    Microsoft released a specific policy to address this exact scenario. This is the cleanest, most reliable approach as it preserves all sync relationships and Files On-Demand functionality.

    For Domain-Joined Computers:

    1. Open Group Policy Management Console
    2. Navigate to: Computer Configuration > Administrative Templates > OneDrive
    3. Enable the policy "Set a custom name for the OneDrive folder"
    4. Specify your desired short name (e.g., OD or OneDrive)
    5. Apply the policy and run gpupdate /force

    For Intune / Azure AD Managed Devices:

    • Deploy the same setting via the OneDrive Administrative Template in Intune (Configuration Profiles > Administrative Templates)

    Once applied, OneDrive will automatically rename the local folder from OneDrive - VeryLongCompanyName to your chosen short name. Existing files remain intact, and no re-sync is required.

     

    Alternative Manual Method (If You Cannot Use Group Policy)

    If administrative policies are not available in your environment, you can safely relocate the folder using this procedure. I recommend testing with a small dataset first.

    1. Exit OneDrive completely — right-click the cloud icon in the system tray and select Exit
    2. Rename the folder — change C:\OneDrive - VeryLongCompanyName to C:\OneDriveShort (or your preferred short name)
    3. Update the registry key — navigate to:

    HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1

    Locate the UserFolder string value and update it to match your new folder path

         4. Restart OneDrive — sign in when prompted. The client will recognize the existing files in the new location and perform a verification scan rather than a full re-download

     

    Important Considerations

    • Windows Long Path Support: As noted by Joel Parmer in the discussion, Windows 10 (1607+) and Windows 11 support paths up to 32,767 characters when the "Enable Win32 long paths" policy is enabled. However, shortening the base path via the methods above remains the more reliable solution, especially for legacy applications.
    • What to Avoid: While symbolic links (mklink /j) may appear to work, they can interfere with Files On-Demand status indicators and are not recommended for the root OneDrive folder.

     

    Summary…

    The Group Policy method is the only fully supported approach that seamlessly renames the folder, updates the sync metadata, and preserves all placeholder states without requiring a re-sync. If you do not have access to Group Policy or Intune, the manual registry method above provides a clean alternative when executed carefully.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

  • jefakems's avatar
    jefakems
    Copper Contributor

    Microsoft recently released this

    https://learn.microsoft.com/en-us/sharepoint/use-group-policy#set-a-custom-name-for-the-onedrive-folder

  • freddavis's avatar
    freddavis
    Copper Contributor

    Long PathTool is a software that will let you easily delete, copy or rename long path files.

    • Chris_Mccormack's avatar
      Chris_Mccormack
      Copper Contributor

      freddavis mklink /j c:\onedrive "C:\OneDrive - My long company name with spaces in"

      then cd c:\onedrive etc

       

      useful if you use the c:\onedrive path in powershell scripts etc

       

      wrap it in cmd /c 'mklink /j c:\onedrive "C:\OneDrive - My long company name with spaces in"' if you're running from powershell

       

      Chris

  • Tim Adams's avatar
    Tim Adams
    Copper Contributor

    Using LongPath Tool program helps in avoiding such errors.

  • MarkPahulje's avatar
    MarkPahulje
    Brass Contributor

    I had ran into this problem constantly and to do this systematically for my customers was a pain. So I built a tool to fix this issue. 
    Path Too Long Auto Fixer (http://pathtoolongautofixer.blogspot.com/) scans for directories and filenames that are longer and 260 characters, and auto shortens them. You have options how the shortening process works, like removing Unicode spaces, hyphens/dashes, underscores and punctuations and more. Try demo for free.

     

  • Stefano Conti's avatar
    Stefano Conti
    Brass Contributor

    successfully done this in my pc:

     

    1) exit One drive app (on icon bottom right, mouse dx > exit)

    2) rename one drive folder from "/vvvveerrrrrrrrryyyyyyyyyyy-llllllllllloooooooonnnnnnnnnngggggggg" ... to "work" or something .. :-)

    3) restart pc.

    4) the onedrive app start to compare the folder content with the online one.

    In my case almost immediately confirm the structure and file prescence (surely not re-downloaded 4GB..)

    bye !

    • Stefano Conti's avatar
      Stefano Conti
      Brass Contributor

      Hi all,

      since yesterday afternoon I successfully changed (renamed) Onedrive name in 5 pc.

      Here the complete working procedure :

       

      1. exit One drive app (on icon bottom right, mouse dx > exit)

      2. rename one drive folder from

        "OneDrive - OldVeryLongNameCompany"     to     "OneDrive - COMPANY"

         

        IMPORTANT: the new "COMPANY" name was previously set in O365 Admin pane (gear icon > Organization profile > name othe Organization.

      3. restart pc.

      4. onedrive app auto-start but does not find the previous folder.

      5. a box appears: RETRY or CONFIGURE. --> CONFIGURE

      6. Input your credentials (O365 account, then password)

      7. OneDrive suggest to use the new renamed folder (into which of course file are yet in).

      8. Choose "use this position" option (or similiar)

      9. OneDrive requires to specify which folders and files you want to sync.
        In my case I wanted to keep synched all files and folders. --> go ahead
      10. the sync start. You can check the status on icon bottom right, initially with double-arrow, but soon it disappears.
      11. In any of our case no further sync was necessary. It just compares the local and remote files information. It took about 5' to check 4GB data (5.000 files).
      12. Once finished, probably the "OneDrive - COMPANY" folder will show all file still in sync (double arrow), while the bottom right icon seems to have finished. --> RESTART PC.

      Enjoy !

      Stefano

      • AKIMF's avatar
        AKIMF
        Iron Contributor

        Hi Stefano Conti,

         

        thanks for the solution. Unfortunately changing the organization name also changes the billing name since it is global. Thus I (currently) may not shorten it.

    • AKIMF's avatar
      AKIMF
      Iron Contributor

      Stefano Conti

      Sadly that doesn't work for me. When I change the folder and restart, I will get the following error message and the client will create new folders and resync the whole data afterwards:

       

       

      Client version .1122, Windows 7

      • AKIMF's avatar
        AKIMF
        Iron Contributor

        Any hint / solution anyone?

        Even with the new client, renaming the base path is not possible.

  • Joel Parmer's avatar
    Joel Parmer
    Brass Contributor

    May not be a solution but information but with Windows 10 build 1607 (Anniversary Edition), the file path limitation of the OS has been lifted to 32,767 giving plenty of space to stretch those file paths out.