F
free404
Guest
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)?
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.
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:
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:
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)?
More...
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.
- Create a folder called A at the root of a Drive.
- Create a sub-folder of A called: B
- Create a sub-folder of B called: C
- Make a FILE in sub-folder C called (no spaces or break, one long continuous string): 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J 123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789S123456789T 123456789U123456789V123456789W123456789X123456.txt
- 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
- 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.)
- 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:
- Note the name of the top folder. Rename it to something very short, say: A (Make sure C:\A does not exist)
- Note the name of the 2nd folder. Rename it to something very short, say: B (Make sure C:\A\B does not exist)
- Note the name of the 3rd folder. Rename it to something very short, say: C (Make sure C:\A\B\C does not exist)
- 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
- Rename D:\A\B\C to D:\A\B\Original_3rd_Folder_name
- Rename D:\A\B to D:\A\B\Original_2nd_Folder_name
- Rename D:\A to D:\Original_top_Folder_name
- 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)?
More...