To solve the problem, you need to find the offending files where the full path and the filename are greater than 255 characters. Since finding the length in a batch file is a bit of a dogs dinner, I use the following VBScript.
Save the code below into a file called
longpaths.vbs. Run it from a DOS command prompt with the following
cscript longpaths.vbs <path> <length> where
<path> is the location of the folder (don't forget to enclose it in quotes if you have a space) and
<length> is the length of the path above which it should flag.
Code is as follows:
If WScript.Arguments.Count <> 2 Then
WScript.Echo "Usage: " & WScript.ScriptName & " <path> <max length>"
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(WScript.Arguments(0)) = False Then
WScript.Echo WScript.Arguments(0) & " - Invalid path or no such folder."
Dim oFolder : Set oFolder = fso.GetFolder(WScript.Arguments(0))
Dim iLength : iLength = CInt(WScript.Arguments(1))
Dim iCount : iCount = 0
WScript.Echo "Looking for paths longer than " & iLength & " characters in " & oFolder.Path
On Error Resume Next
On Error Goto 0
WScript.Echo "Found " & iCount & "."
Dim oFile : For Each oFile in oScanFolder.Files
If Len(oFile.Path) > iLength Then
iCount = iCount + 1
For Each oFile in oScanFolder.SubFolders
Sample usage and output:
D:\Development>cscript longpath.vbs c:\Windows 210
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Looking for paths longer than 210 characters in C:\Windows
Once you know the problem files, you can either rename them so they are shorter, rename one of the folders in that path or (possibly) map a network drive to a sub-folder in that path which will reduce the length of the path.