Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was copying a bunch of files but wasn't able to copy some because there name was too long. Is there an easy way to shorten the names or can I at least know the path to where the file name becomes too long?

EDIT: by bunch of files I mean there are two directories each containing files and more directoris containing more files etc. I'm simply copying by ctrl+c

share|improve this question
What does "bunch of files" mean? Was this a big directory or lots of individual files? How were you attempting the copying and what was the message or popup you got? You haven't told us enough to know exactly what the problem is and how to help you. –  Nicole Hamilton Jan 12 '13 at 19:55
down voter got guts to comment? –  Celeritas Jan 13 '13 at 9:18

5 Answers 5

You can use Path Scanner to find the offending files. (Scroll to the bottom to Old Path Scanner)

share|improve this answer

I would suggest Robocopy, builtin in Windows 7.

robocopy <Source> <Destination> [<File>[ ...]] [<Options>]
share|improve this answer
how does that help with long file names? –  Celeritas Jan 12 '13 at 21:55
I misunderstood your question, thought you having problems copying long files. –  Ofiris Jan 13 '13 at 6:00

If you're okay with a command-line solution, the cp utility I include with Hamilton C shell will easily copy your files without any need to shorten anything. (Full disclosure: I'm the author.) Like the rest of my basic file utilities, it uses long Unicode filenames internally to support path lengths up to 32K characters, the system limit.

If this is a one-time thing (and possibly even if it's not) all you need is the free version. Let me know if encounter a problem or need help getting it to do what you want.

share|improve this answer

You don't say what OS you're using. If Windows, TeraCopy is a great program (the free version perfect for most everybody) that I use for copying/moving files. Unlike Windows, TeraCopy will not fail completely when encountered with problematic files. It can be used as-needed, or replace the Windows copy functionality with its own. Here's a blurb:

TeraCopy is designed to copy and move files at the maximum possible speed. It skips bad files during the copying process, and then displays them at the end of the transfer so that you can see which ones need attention. TeraCopy can automatically check the copied files for errors by calculating their CRC checksum values. It also provides a lot more information about the files being copied than its Windows counterpart. TeraCopy integrates with Windows Explorer's right-click menu and can be set as the default copy handler

share|improve this answer
The question uses the Windows 7 tag. Presumably that confirms what you were thinking: Windows is being used. –  TOOGAM Jan 27 at 12:15

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:

Option Explicit
If WScript.Arguments.Count <> 2 Then
    WScript.Echo "Usage: " & WScript.ScriptName & " <path> <max length>"
End If
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."
End If
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
Call ScanFolder(oFolder)
On Error Goto 0
WScript.Echo "Found " & iCount & "."
Sub ScanFolder(oScanFolder)
    Dim oFile : For Each oFile in oScanFolder.Files
        If Len(oFile.Path) > iLength Then
            WScript.Echo oFile.Path
            iCount = iCount + 1
        End If
    For Each oFile in oScanFolder.SubFolders
        Call ScanFolder(oFile)
End Sub

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
Found 1.


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.

share|improve this answer

protected by Journeyman Geek Jan 19 '14 at 15:26

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.