Locate Files with Paths that Exceed the Windows Limit

Summary

Windows has a limit of 256 characters for file and folder paths. Here is an easy way to identify problematic files.

Information​​​​​​

File and folder paths that exceed 256 characters can cause issues in Windows. While you may not notice issues accessing the files in Windows Explorer, you may encounter trouble when attempting to delete, move, and rename them. Here is a script that you can use to identify files and folders with long paths.

Edit this command:

cmd /c dir T:\ /s /b /a |? {$_.length -gt 256}|Out-File C:\users\XXXX\desktop\filelist.txt
  • T:\ is the local folder to scan. You can change this to a subfolder first to see how long it takes to scan a subset.
  • 256 is the length variable. Keep in mind that some file operations may not work even with a source path less than 256 characters, especially when trying to move files from a shorter path to a longer one.
  • The last path is the local path to save the text file containing the results.

Once you have updated the path to your liking, highlight it and then copy it.

Click the Start Menu, type "powershelll", then click the Windows PowerShell icon when it appears.

In the PowerShell window, right-click your mouse button and it should paste the command. Then hit ENTER.

Once it's done, check your text file for the output.

Print Article

Details

Article ID: 147414
Created
Tue 10/25/22 2:43 PM
Modified
Mon 10/2/23 6:52 AM