Results 1 to 8 of 8
  1. #1
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts

    Searching for long file names

    While I was copying files from one folder to another, I got a warning that there were filenames included that were longer than 256 characters. Rather than dealing with each one at that time, I just continued the copying.

    Is there a process or program that I can use to scan a folder and find all the files with "too long" names, and move them so that I can then deal with them -- rename perhaps -- later?

    Regards,
    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Chuck,

    You really have file names that are that long? Are you sure it isn't the File spec, e.g. drive\path\filename.ext?
    The only work around I know is to flatten your tree out (fewer levels) or to copy at a lower level. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    RG, no, it's the whole path, and in fact I never actually saw a problem, so I guess I just shouldn't worry about it.

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  4. #4
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,164
    Thanks
    47
    Thanked 976 Times in 906 Posts
    Windows doesn't have a length issue, but Windows Explorer does. The easiest way to fix the issue is to rename (shorten) the folder names that contain the offending files until you can work with the files themselves. Alternatively use Robocopy to move the files to a shorter path.

    cheers, Paul

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Paul,

    Both MS & I disagree.
    Maximum Path Length Limitation

    In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)
    Here's the full article on MS Tech Net.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. #6
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,164
    Thanks
    47
    Thanked 976 Times in 906 Posts
    RG, I've used / fixed many a long path in Windows, but it may be because I was working with servers / 64bit software.

    cheers, Paul

  7. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Paul,

    Yes, the hardware/software can be very different on servers.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  8. #8
    Super Moderator Rick Corbett's Avatar
    Join Date
    Dec 2009
    Location
    South Glos., UK
    Posts
    2,138
    Thanks
    101
    Thanked 576 Times in 461 Posts
    Copy/paste the following into a Notepad file and save it as FilepathChecker.vbs:

    Code:
    Dim oShell
    Set oShell = CreateObject("Wscript.Shell")
    
    Const FOR_READING = 1
    strFolder = InputBox("Enter the filepath (local or UNC) you wish to query, e.g. C:\Windows or \\server\share$\folder")
    'strFolder = "C:\Windows"
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Create a file to pipe the results to
    LogFileName = oShell.SpecialFolders("Desktop") & "\FilePathLength.txt"
    Set fsHandle = objFSO.OpenTextFile (LogFileName,8,True)
    
    'Recurse through folders and get the full path of files, inc. in sub-folders
    Set objFolder = objFSO.GetFolder(strFolder)
    fsHandle.Writeline objFolder.Path
    Set colFiles = objFolder.Files
    For Each objFile In colFiles
      fsHandle.Writeline "(" & Len(objFile.Path) & " Chrs) " & objFile.Path
    Next
    ShowSubFolders(objFolder)
     
    Sub ShowSubFolders(objFolder)
      Set colFolders = objFolder.SubFolders
      For Each objSubFolder In colFolders
        fsHandle.Writeline objSubFolder.Path
        Set colFiles = objSubFolder.Files
        For Each objFile In colFiles
          fsHandle.Writeline "(" & Len(objFile.Path) & " Chrs) " & objFile.Path
        Next
        ShowSubFolders(objSubFolder)
      Next
    End Sub
    
    oShell.Popup "Check the FilePathLength.txt file on your desktop.", 3, "Path length checker"
    
    Wscript.Quit()
    When you run it you'll be asked to enter a starting point (like C: or C:\Windows, etc.) When it's finished there'll be a text file on your desktop called FilePathLength.txt. In the file you will see a list of your files prefixed by the numbers of characters. Tested on Windows XP and Windows 7.

    Hope this helps...

  9. The Following User Says Thank You to Rick Corbett For This Useful Post:

    cmptrgy (2015-10-29)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •