Folder redirection issue

Shahin Mortazave 486 Reputation points
2020-09-24T09:18:54.807+00:00

Hi,

We having an issue with our folder redirection to onedrive for osme of our users.

We have a policy that will automatically move the users data from the current location to the Onedrive. Policy works, but we have 3 users that thier files dont get copy to the onedrive. We did check the event logs and can see the event 502 folder redirection error that talk about long folder or extention names.

Any idea how can we get a list of all the folders and files that have a long name? Or it would be beter if we could solve the issue without asking the users to shorten thier folders paths.

We have Windows 10 ent as client.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,525 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
11,739 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Daisy Zhou 17,241 Reputation points Microsoft Vendor
    2020-09-25T06:35:50.33+00:00

    Hello @Shahin Mortazave

    Thank you for posting here.

    We can find the long folder or extention names with the following command:

    cmd /c "dir /b /s /a C:\Users\administrator\Documents" | ForEach-Object { if ($.length -gt 250) {$ | Out-File -append C:\longfilepath.txt}}

    For example:
    28197-ps2.png

    Or

    Get-ChildItem -Path C:\Users\administrator\Documents -Recurse | Where-Object {$_.FullName.Length -gt 250 }| Select-Object -ExpandProperty FullName | Out-File C:\longfilepath.txt

    For example:
    28234-ps1.png

    From the article below, we can define the length of characters as 260 or shorter if needed.

    MAX_PATH: This is the maximum length of a path according to the Windows API, defined as 260 characters.

    Long Paths in .NET, Part 1 of 3 [Kim Hamilton]
    https://learn.microsoft.com/zh-cn/archive/blogs/bclteam/long-paths-in-net-part-1-of-3-kim-hamilton

    Here is a similar case, we can refer to it.

    Redirect folder redirection: "Failed to apply ... The filename or extension is too long."
    https://social.technet.microsoft.com/Forums/en-US/9a63ec84-90b0-4d7c-8219-e59d736b917c/redirect-folder-redirection-quotfailed-to-apply-the-filename-or-extension-is-too-longquot?forum=winserverfiles

    Hope the information is helpful.

    Best Regards,
    Daisy Zhou

    0 comments No comments

  2. Shahin Mortazave 486 Reputation points
    2020-09-25T08:18:23.563+00:00

    Thanks for your reply,

    Both the cmdlet returen an error, so I did run this cmd /c dir /s /b |? {$_.length -gt 256} and show me the files with long names.

    I read also that we can enable the"Enable the Win32 long paths" policy in Windows 10. Does this policy only going to work with 32 bit APIs or enabling this will also solve the issue that we have as well?

    Thanks