none
File name too long cannot copy (cont'd)

    General discussion

  • This is a continuation of the post started September 01, 2009, with the last post on October 17, 2011 named File name too long cannot copy

    Since this is an ongoing unsolved issue, and the thread was locked, it continues here.

    It is ever so easy to create a long file/path using explorer.exe as will be shown below.

    What needs to be solved is, what is an easy way (no, not by listing out all the files in a directory to a text file and counting characters), perhaps using a shell extension, to find out which files in a directory and it's subdirectories will be (or were) too long to copy, (and then perhaps even copying those over either intact or renamed)?

    Maflagulator said:

    I'm running the 7100 build...enjoying it except for one big thing:

    While attempting to copy 402gb from my main storage volume onto a spare 500gb drive (for the purpose of changing to a new RAID array) I've come across something that I would expect a Windows 98 OS to give me.

    It tells me that a file has TOO LONG of a file name, then provides with two unhelpful options: SKIP or CANCEL

    I never had XP give me an issue like this at all, so what gives? And while some specific files did have long file names (such as for songs, etc.) it had 7 issues with folders stating that their name was too long, but in fact they were not since they were titled '07-06-07' for the date that I dumped the audio files in them. However, they may have contained FILES with long file names though.



    Anyone else get this same situation? Perhaps the RTM version does not do this? Can anyone verify this regarding their install of the RC or the RTM?

    It made it through 400gb out of the 402gb transfer.

    I'm just happy to see that it doesn't spazz out about an issue like this until it has done all the other transfers that it can do because it saves the issues it has with files until the very end. In XP it would spazz about it the moment it came across it causing the transfer process to halt.

     


    Since long path/file names can so easily be created on Win7, it might be useful to see a typical way this happens, which might then give clues how to work with them.

    In Windows Vista, we learnt from: File names and file name extensions: frequently asked questions that:

    Windows usually limits file names to 260 characters. But the file name must actually be shorter than that, since the complete path (such as C:\Program Files\filename.txt) is included in this character count.

    In Windows 7, we are told here: File names and file name extensions: frequently asked questions that:

    It depends on the length of the complete path to the file (such as C:\Program Files\filename.txt). Windows limits a single path to 260 characters. This is why you might occasionally get an error when copying a file with a very long file name to a location that has a longer path than the file's original location.

    From the Windows Dev Center - Desktop, we read about Maximum Path Length Limitation here: Naming Files, Paths, and Namespaces

    This helps us understand why a folder can be a maximum of 244 characters, from the defined 260 length of MAX_PATH as follows:
    260 minus C:\ (3) minus <NUL> (1) = 256
    256 minus 8.3 file name (12) = 244

    We also learn there that: The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters.

    And we read the claim that: The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not be able to interpret properly.

    There is also a comment below this document that reads: In a previous iteration of this document, it is mentioned that The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. This information is now gone.


    So we are in a position where the file system and Windows API can create long path/flies that the shell cannot handle.
    But then we need to be able to handle it, so a little exploration might lead to a better understanding of how to do this.

    For most tasks being performed on long folder/files, Windows 7 and other Windows programs balk when the Path+Filename length > 260

    Let's create a long path/file.

    1. Create a folder called A at the root of a Drive.
    2. Create a sub-folder of A called: B
    3. Create a sub-folder of B called: C
    4. Make a FILE in sub-folder C called (no spaces or break, one long continuous string): 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X123456.txt
    5. Rename sub-folder C to the string (no spaces or break, one long continuous string) (The actual directory created will be slightly shorter than this full length): 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X123456789Y123456789Z
    6. Rename sub-folder B to the same full string above. (The actual directory created will be slightly shorter than this full length but 2 characters longer than the step above.)
    7. Rename folder A to that same full original string. (Again the actual directory created will be slightly shorter than this full length but 2 characters longer than the step above.)

     

    You now have the lovely file placed at (the breaks are just so it fits into the screen):

    C:\123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X1234\ 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X12\ 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X\ 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X123456.txt

    You have a folder length of over 700 and a file length of over 250 for a total of over 950

    However you will notice that each folder, when created, could only be a maximum of 247 charachters including the path (example C:\ , & C:\A , & C:\A\B

    This only applies backwards, that is up the path. It did not matter what was further down the path.

    Now, you can't easily access or rename the file, but you can rename the folders easily.

    For best results, start renaming from the top of the Tree, working down the subfolders, because renaming from down up will limit you, and in fact won't work if the folder lengths are too long.

    So how might knowing this help us?

    Well, to copy this long_file from the C:\ drive to the D:\ drive, and keeping the path structure, this should work:

    1. Note the name of the top folder. Rename it to something very short, say: A (Make sure C:\A does not exist)
    2. Note the name of the 2nd folder. Rename it to something very short, say: B (Make sure C:\A\B does not exist)
    3. Note the name of the 3rd folder. Rename it to something very short, say: C (Make sure C:\A\B\C does not exist)
    4. Make sure D:\A does not exist - then copy the A folder on disk C: to disk D: (which gives you D:\A\B\C\long_file
    5. Rename D:\A\B\C to D:\A\B\Original_3rd_Folder_name
    6. Rename D:\A\B to D:\A\B\Original_2nd_Folder_name
    7. Rename D:\A to D:\Original_top_Folder_name
    8. Rename C:\A\B\C back to their original names, in this same reverse order starting with C, then B, then A

    Note: If using Explorer, at some points you might have to press the F5 refresh key.

    This is of course how you might copy such long path/files without using the other more "easy" techniques for the "normal" everyday user like:

    • sharing a sub-folder
    • using the commandline to assign a drive letter by means of SUBST
    • using AddConnectionunder VB to assign a drive letter to a path
    • using the "\\?\" prefix to a path string to tell the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system
    • and so on.

    See how simple Windows can be for Dummies!

     

    But then, how can we know that files to be copied exceed this MAX_PATH? Or also after a copy has taken place, know exactly which files that have NOT been copied because of exceeding the MAX_PATH limit, and then a procedure to copy these either by renaming them, or by copying them intact as they are?

    There have been suggestions to use LongPathTool, but this does not have a facility to check a series of folders and tell you which files are going to be caught by the error when copying. So once a copy has taken place using Windows 7, one does not know which files did not get copied, and where exactly they are located.

    Neither does the free Old Path Scanner do that. It can only check for overly long directory paths, but misses out when the directory path is within limits, but adding in the file name puts it out of bounds.

    So, as shown above, it is ever so easy to create a long file/path using explorer.exe

    So, what then is an easy way (no, not by listing out all the files in a directory to a text file and counting characters), perhaps using a shell extension, to find out which files in a directory and it's subdirectories will be (or were) too long to copy, (and then perhaps even copying those over either intact or renamed)?




    Monday, January 02, 2012 9:07 AM

All replies

  • Is this a question or discussion?
    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Wednesday, January 04, 2012 1:02 AM
  • The questions and discussions on the issue of File Names are too long, cannot copy, are here. There appeared no viable easy solution(s) for non-technical users in that locked thread. There was no other similar open thread.  One roundabout method of achieving the goal of copying a long path/file is given above, but it is cumbersome. Hopefully the discussion and questions will continue, leading possibly to an answer that is convenient.

    Would anyone happen to know if this conundrum will continue into Windows 8?

    Wednesday, January 04, 2012 3:38 AM
  • The questions and discussions on the issue of File Names are too long, cannot copy, are here. There appeared no viable easy solution(s) for non-technical users in that locked thread. There was no other similar open thread.  One roundabout method of achieving the goal of copying a long path/file is given above, but it is cumbersome. Hopefully the discussion and questions will continue, leading possibly to an answer that is convenient.

    Would anyone happen to know if this conundrum will continue into Windows 8?


    Thanks free404! Would you mind adding the question to the top of your first post? That way we can try to get an answer to the specific question?

    Otherwise, would you be up for changing this to a Discussion type instead?

    Thanks!


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Wednesday, January 04, 2012 11:51 PM
  • Use Linux to fix this.  Create a dual-boot system.  Use If you need Windows, your dual boot system will always have it there for you.  Most forms of Linux allow a file path length of 4,096.  They also allow file NAME lengths of 255, which is the whole PATH length in Windows 7! 

    UNIX, the basis of Linux, was developed 40 years ago!  Somehow Linux can get it right but Microsoft can not.  But then again, the volunteer Linux developers work like professionals, while Microsoft is a poorly managed business that fritters away billions of dollars in development costs while producing technology that is retrograde. 

    TO MY POINT, not ONE post related to Windows file name length problems includes a reply with Microsoft's approach to FIXING the OS file path length problem.  That is because Microsoft does NOT focus on creating solutions - they focus on SALES and any quality that might arise is literally a side effect.  Linux developers focus on quality, and that is why their FREE operating system is still better than Windows 40 years after UNIX was written.  I wish that were not true, since I paid for Windows 7, but it is true.  :-b

    Thursday, February 16, 2012 1:50 PM
  • Hi, Ed.  I'm a newbie to this forum, though my group at the company I worked for got our first PCXTs in 1984 and those insane IBM people went and Really Over-did it and put a 10 - Repeat TEN Megabyte Hard Disk in them.  What in the world could anyone do with so much space???  We had DOS (PCDOS?) 1.1 or some such and the DOS program Displaywrite word processing software on it and we had to buy the cabling and software in order to convert the data from our 8" toaster drives on ourIBM "Displaywriter" word processor over to the XTs.  And, yes, I'm older than dirt *g*.  Since that momentous time, I've been associated with a number of so called PC / X86 variants.  Plus, I've said things too many times to count about Microsoft that would make a hardened sailor blush.

    With that said, Jim, AKA "Why use one word where two will do" from some 2011 posting was about the best and rational explanation and concise question:  "WHY HAS MICROSOFT ALLOWED US TO CREATE PATHNAMES+ FILENAMES OF SUCH A LENGTH THAT EVEN THE SAME SOFTWARE CANNOT COPY THEM?????"

    The man had a good question.

    I understand your asking free404 to add their question to the top of the first post, but, uh, er, um, don't you work for said company?  Now, I understand that more often than not, a company will listen to a potential customer than someone sitting next to them.  Crazy, but I've seen it many, many times.  And, I believe Scott Adams with Dilbert covers such things pretty well.

    But, back to the point.  I'll pose my own version of the question:  WHY HASN'T MICROSOFT COME UP WITH A FIX/UPGRADE TO IMMEDIATELY CORRECT THIS PROBLEM?

    Sure, its easy for me to propose such a question and perhaps not so easy for a programmer to sit down for 10 minutes and write the code to make this fix, but I can still ask.  I get numerous upgrades from Microsoft all the time and I assume those are designed to do something useful.  Yes, they give an explanation of what each file is supposed to do, but I'm sure there is more to "This fix helps Windows 7 correct a significant issue with the system inertial dampers." *smile*

    Anyway, just for academic reasons if nothing else, what is the path from yourself, maybe even including letters like this one, to go through the MS bureaucracy and actually get to a programmer who is assigned to actually write a program with the intent to sending it out with other upgrades?  I have a feeling there are quite a few steps between here and then and the vast majority of ideas don't get past the first reviewer and die on the vine.  But, that's just one man's opinion.

    Have a good week,

    Randy

    Ps:  If you have a way to send my message to Jim, AKA "Why use one word where two will do", please do that for me.  He may have setup an ID just for that one posting and not use his ID all the time and I understand such things. - Thanks, TRW

    Monday, June 25, 2012 2:03 AM

  • Cornelius Pone's very nicely made gif file !

    Would anyone happen to know if this conundrum will continue into Windows 8?

    Cornelius,

    Thank you for confirming this has not been fixed as of Windows 8 Release Preview Build 8400.

    Hopefully it still might be fixed before Win 8 launches.

    I wonder what the odds of that might be?

    Friday, July 06, 2012 6:56 PM
  • I can confirm that this is still an issue with server 2012. Migrating files from a server 2008 to 2012 gave two instances of the "file is too long to copy" error. Why does the error dialogue box not tell you the path, and then give you the opportunity to find the original file to rename or an option to rename the new copied file??? 

    Thursday, September 06, 2012 10:31 PM
  • Hello...Path to long/deep? I can give a small suggestion. Then you may be able to delete, remove, renaming and others. Long Path Tool helped me in this situation, so at lest you can download “Long Path Tool" for solve this problem. Thank you so much.
    Sunday, October 14, 2012 3:40 PM
  •  I don't know if you need this but..

     you could use attrib,  xcopy and dir from a batch file or just at the command prompt

    use attrib/? and xcopy/? and dir/? for more info on switch's

    use this from the root folder like C:\attrib +a /s

    this will turn the archive attribute on

    then do C:\xcopy  source [destination] /m

    then xcopy only copy's files with the  archive  attribute on and turn's it off after it's been copied.

    then you can use C:\dir /s /a:-a > files_not_copied.txt and this text file will have all the files not xcopyed.

    I guess it would be worth it to test xcopy first and see if it craps out like copy.

    Sunday, October 21, 2012 5:19 PM
  •  I don't know if you need this but..

    "Rowindas" is a habitual troll in this forum. Please do not feed him/her.
    Sunday, October 21, 2012 7:44 PM
  • Hello...Path to long/deep? I can give a small suggestion. Then you may be able to delete, remove, renaming and others. Long Path Tool helped me in this situation, so at lest you can download “Long Path Tool" for solve this problem. Thank you so much.

    You fail to mention that you have to pay for the software before you can use the rename feature.  No help at all.
    Monday, December 17, 2012 7:58 AM
  • The whole convoluted text of the 'solution' is useless.

    Give me a free, easy to use file renaming solution.  You would think that Microsoft would have done something by now in the Windows 7 patches....

    Monday, December 17, 2012 8:00 AM
  • ROBOCOPY copies long paths, but it's a command line tool.

    I found a low-tech solution for locating the files with long paths (this was on a Windows 2008 server).  I realize this is only practical for searching folders with a relatively small number of offending paths. 

    In DOS, CD to the folder you want to search.  Do a directory listing with the /s switch.  I piped it to a text file, for example 

    dir /s > list.txt. 

    The DOS window will then display only the file paths that are too long.  Use the DOS window's "select all" and "copy" tools to paste the results into another text file. 


    • Edited by RMOMCSE Thursday, January 24, 2013 3:41 PM
    Thursday, January 24, 2013 3:41 PM
  • This is a not a "solution" ....but a "work around": a low tech fix....for error message "your file name is too long to be copied, deleted, renamed, moved" :

    1.   problem is this: the "file name" has a limit on number of characters.....the sum of characters really includes the entire path name; you gotta shorten it first (i.e, if the total number of characters in the file name + Path name are over the limit, the error appears).  The deeper your file folder sub levels are, the more this problem will come up, especially when you copy to a subfolder of a subfolder/subfolder of another path ...adds to character limit)

    2.  How do you know which combined file names + path names are too long if  you are in the  middle of a copy operation and this error pops up?  Some files copied but the "long files error message" says "skip" or "cancel" ... but not which files are the "too long" ones.  If you hit "skip" or "cancel" the "too long" files are left behind...but are mixed in with non-offender "good" "short name" files.   Sorting thru 1000s of "good" files to find a few "bad" ones manually is impractical.

    3.   Here's how you sort out the "bad" from the "good":

    4.    Let's say you want to copy a folder ..."Football" ...that has five layers of subfolders; each subfolder contains numerous files:

      C:/1 Football / 2 teams/ 3 players/ 4 stats/ 5 injuriessidelineplayerstoolong 

           There are five levels root "1 football" with subfolders  2, 3, 4 and lastly "5 injuries"

    5.    Use "cut" and "paste"  (for example to backup all five levels to a new backup folder):

           select "1 football" ....cut....select target folder....paste 

           ("cut" command means as the files are copied to the target destination, the file is deleted from the source location)

          Hint: avoid "cut" and "paste" to a target folder that is itself a sub/sub/sub folder ...that compounds the "characters over the limit" problem ...because the characters in the sub/sub/sub folder are included in the "file name character limit"...instead "paste" to a C:/ root directory.

           Suppose in the middle of this operation...error pops up: "5 files have file names that are too long"  Skip or cancel?

           select "skip"  ...and let operation finish

    6.    Now go back and look at the source location: since the software allows only the "good" "short name" files to be copied (and because you "skipped" the "bad" "Long name" files so they are not copied or deleted) ...all that remains in the source location are the "bad" "long name files" (because "good" ones were deleted from the source location after the "cut" operation...the bad ones stick out like a sore thumb.

    7.   You will find ....all that remains in source folders are: the "bad" "too long" files; in this example the "bad" file is in level 5:

          C:/ 1 football / 2 teams /3 players /4 stats /5 injuriessidelineplayerstoolong

    8.   select folder 5 injuriessidelineplayerstoolong (that's right...select folder, not file) gotta rename the folder first.

    9.  hit F2 rename folder..folder name highlighted...delete some of the letters in the folder name:

           like this:   5 injuriessidelineplayers  ....you should delete 'toolong'....from the folder name

    10.  then go into folder 5....and do the same operation ...with the too long file name:

            hit F2 rename file....file name hightlighted...delete some of the letters

               like this:  injuriessidelineplayers.....you should delete 'toolong' from the file name

    11.  Now..."cut and paste"  the renamed file to the target backup folder.  

    The Error message will pop up again if you missed any "bad" files....for example, it will indicate "5 files too long" ....then repeat process 5 times until you fix all of them

    12.     Finally, copy the target destination files back to the source location (when you are certain all source location file folder locations are empty) 

    Of course, this "makeshift" solution would not be necessary if MSFT would fix the problem...

    Sunday, February 10, 2013 10:11 PM
  • Use Long Path Tool, a great solution for renaming copying and deleting files taht has long filename and paths.
    Tuesday, November 05, 2013 9:26 PM
  • Use Long Path Tool, a great solution for renaming copying and deleting files taht has long filename and paths.
    The usual advertisement for this "tool", repeated ad nauseum . . .
    Tuesday, November 05, 2013 9:59 PM